Compare commits

...
60 Commits
Author SHA1 Message Date
Tanner Linsley 379d9e11d5 v6.9.0 2019-01-31 10:18:22 -07:00
John MaguireandTanner Linsley 3fff682578 apply @twheys PR #1077 as patch and update Array.concat to [].concat (#1241) 2019-01-31 10:15:09 -07:00
Josh McCulloughandTanner Linsley 168a8e3f93 update fireFetchData to use current state for select value (#1231) 2019-01-31 10:09:28 -07:00
Josh McCulloughandTanner Linsley 221164484f cleanup all but one linting issue (#1232) 2019-01-31 10:08:31 -07:00
Andrej GajdosandTanner Linsley c7d2c36454 adding position prop into pagination component (#1205)
- adding isTop prop into pagination component, which allows
differentiate if pagination is on top or bottom of the table
2019-01-31 10:08:06 -07:00
Laurent PandTanner Linsley 26961d0994 [fix] filter data on all available columns not just visible one (#1148) 2019-01-31 10:07:06 -07:00
Devin ClarkandTanner Linsley de6389cafc Adding IDs for select table, fixing backwards compatibility on floating left checkbox (#1208)
* Adding IDs for select all and individual row checkboxes

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

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

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

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

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

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

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

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

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

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

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

* update readme

* update examples and src

* edit readme

* use single instance of advancedExpandTable

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

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

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

* Edit link to working codesandbox

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

Closes #870

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

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

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

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

* remove accidentally committed file
2018-05-24 16:27:57 -06:00
Bill FienbergandTanner Linsley 72afabbd03 Fix README: defaultSortMethod doesn't match code (#910)
Updating the `defaultSortMethod` in the README to match the [code](https://github.com/react-tools/react-table/blob/3a8a037ee68b11e329c581a8d61a37db276a0dbf/src/defaultProps.js#L46)
2018-05-24 16:25:57 -06:00
Stuart CasarottoandTanner Linsley 4aa07c33da Typo (#899)
arra -> array
2018-05-24 16:25:41 -06:00
Frank NguyenandTanner Linsley d430d51888 Added react-dom as a peer dependency (#889) 2018-05-24 16:25:28 -06:00
AndrewandTanner Linsley 4824b4c8cc Remove header focus outline. Fixes react-tools/react-table#685 (#881) 2018-05-24 16:24:54 -06:00
Richard AandTanner Linsley 60766cf261 Add prefix to key of pad rows (#828)
Add prefix to key of pad rows so it doesn't conflict with keys of page rows.
Duplicate keys are causing rendering issues with preact.
2018-05-24 16:23:53 -06:00
Tanner Linsley fcdc3d88bc v6.8.6 2018-05-24 10:24:29 -06:00
Tanner Linsley 24a9efd670 v6.8.5 2018-05-19 00:47:17 -06:00
Tanner Linsley bdb7d44438 v6.8.4 2018-05-18 17:34:41 -06:00
Tanner Linsley 7a6ed50b81 Make data prop required, but allow it to be anything. 2018-05-18 17:34:03 -06:00
Tanner Linsley 8f062550aa v6.8.3 2018-05-18 17:32:04 -06:00
36 changed files with 10126 additions and 560 deletions
+1
View File
@@ -0,0 +1 @@
* text=auto
+38
View File
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Codesandbox!**
Use a new [react-table codesandbox](codesandbox.io/s/X6npLXPRW) to reproduce the issue.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
+17
View File
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -0,0 +1,11 @@
---
name: Questions, Support & Help
about: Looking for help? Need a question answered?
---
STOP!!!
Github issues is no place for general support. We encourage you to use our public support forum at https://spectrum.chat/react-table.
NOTE: If a support/help/question issue is opened, it will be closed immediately and be redirected to the forum. Thanks for helping us keep our issues clean and productive!
+1
View File
@@ -8,3 +8,4 @@ react-table.css
*.log
.idea
.DS_Store
.history
+18
View File
@@ -1,3 +1,21 @@
## 6.8.6
#### Fixes & Optimizations
* Since `resolveData` is now capable of materializing data on it's own, the `data` prop is no longer required as a prop-type.
## 6.8.4
#### Fixes & Optimizations
* Only run `resolveData` prop when `data` prop has changed, not any others.
## 6.8.3
#### Fixes & Optimizations
* Allow the `resolveData` prop to alter or materialize new data when the `data` prop changes.
## 6.8.1
#### Fixes & Optimizations
-18
View File
@@ -1,18 +0,0 @@
## What version of React-Table are you using?
Your bug may already be fixed in the latest release. Run `yarn upgrade react-table`!
Place your version here...
## What bug are you experiencing, or what feature are you proposing?
Please include a detailed explanation here...
## Use https://codesandbox.io/s/X6npLXPRW (by clicking the "Fork" button) to reproduce the issue.
Then paste a link to your newly forked codesandbox here...
## What are the steps to reproduce the issue?
1. list the steps
2. to reproduce
3. the issue
+170 -110
View File
@@ -12,8 +12,8 @@
<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://react-chat-signup.herokuapp.com/" target="\_parent">
<img alt="" src="https://img.shields.io/badge/slack-react--chat-blue.svg" />
<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/react-tools/react-table" target="\_parent">
<img alt="" src="https://img.shields.io/github/stars/react-tools/react-table.svg?style=social&label=Star" />
@@ -30,47 +30,64 @@
## Features
* Lightweight at 11kb (and just 2kb more for styles)
* Fully customizable (JSX, templates, state, styles, callbacks)
* Client-side & Server-side pagination
* Multi-sort
* Filters
* Pivoting & Aggregation
* Minimal design & easily themeable
* Fully controllable via optional props and callbacks
* <a href="https://medium.com/@tannerlinsley/why-i-wrote-react-table-and-the-problems-it-has-solved-for-nozzle-others-445c4e93d4a8#.axza4ixba" target="\_parent">"Why I wrote React Table and the problems it has solved for Nozzle.io"</a> by Tanner Linsley
- Lightweight at 11kb (and just 2kb more for styles)
- Fully customizable (JSX, templates, state, styles, callbacks)
- Client-side & Server-side pagination
- Multi-sort
- Filters
- Pivoting & Aggregation
- Minimal design & easily themeable
- Fully controllable via optional props and callbacks
- <a href="https://medium.com/@tannerlinsley/why-i-wrote-react-table-and-the-problems-it-has-solved-for-nozzle-others-445c4e93d4a8#.axza4ixba" target="\_parent">"Why I wrote React Table and the problems it has solved for Nozzle.io"</a> by Tanner Linsley
## [Demos and examples](http://react-table.js.org/#/story/simple-table)
## Versions
* This documentation is for version 6 of react-table.
* [View the Changelog](https://github.com/react-tools/react-table/blob/master/CHANGELOG.md)
* Previous versions:
* [5.x.x Readme](https://github.com/react-tools/react-table/blob/ad7d31cd3978eb45da7c6194dbab93c1e9a8594d/README.md)
- This documentation is for version 6 of react-table.
- [View the Changelog](https://github.com/react-tools/react-table/blob/master/CHANGELOG.md)
- Previous versions:
- [5.x.x Readme](https://github.com/react-tools/react-table/blob/ad7d31cd3978eb45da7c6194dbab93c1e9a8594d/README.md)
## Sponsors
| | |
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![Platinum Sponsors](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/platinum.png)](https://patreon.com/tannerlinsley) | [![Retool](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/sponsor-retool.png)](https://tryretool.com/?utm_source=sponsor&utm_campaign=react_table) |
| | | |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [![Gold Sponsors](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/gold.png)](https://patreon.com/tannerlinsley) | [![Retool](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/gold-placeholder.png)](https://patreon.com/tannerlinsley) | [![Retool](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/gold-placeholder.png)](https://patreon.com/tannerlinsley) |
| | | | |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| [![Silver Sponsors](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver.png)](https://patreon.com/tannerlinsley) | [![Retool](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver-placeholder.png)](https://patreon.com/tannerlinsley) | [![Retool](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver-placeholder.png)](https://patreon.com/tannerlinsley) | [![Retool](https://raw.githubusercontent.com/tannerlinsley/files/master/images/patreon/silver-placeholder.png)](https://patreon.com/tannerlinsley) |
**React Table v7** is mostly planned and I (@tannerlinsley) am looking for Patreon support to make it a reality. It will require a decent time commitment on my part to not only implement it, but also help people migrate and maintain it. If you would like to contribute to my Patreon goal for v7, [visit my Patreon and help me out!](https://patreon.com/tannerlinsley). Gold
## Table of Contents
* [Installation](#installation)
* [Example](#example)
* [Data](#data)
* [Props](#props)
* [Columns](#columns)
* [Column Header Groups](#column-header-groups)
* [Custom Cell and Header and Footer Rendering](#custom-cell-header-and-footer-rendering)
* [Styles](#styles)
* [Custom Props](#custom-props)
* [Pivoting and Aggregation](#pivoting-and-aggregation)
* [Sub Tables and Sub Components](#sub-tables-and-sub-components)
* [Server-side Data](#server-side-data)
* [Fully Controlled Component](#fully-controlled-component)
* [Functional Rendering](#functional-rendering)
* [Multi-Sort](#multi-sort)
* [Filtering](#filtering)
* [Component Overrides](#component-overrides)
* [Contributing](#contributing)
* [Scripts](#scripts)
* [Used By](#used-by)
- [Installation](#installation)
- [Example](#example)
- [Data](#data)
- [Props](#props)
- [Columns](#columns)
- [Column Header Groups](#column-header-groups)
- [Custom Cell and Header and Footer Rendering](#custom-cell-header-and-footer-rendering)
- [Styles](#styles)
- [Custom Props](#custom-props)
- [Pivoting and Aggregation](#pivoting-and-aggregation)
- [Sub Tables and Sub Components](#sub-tables-and-sub-components)
- [Server-side Data](#server-side-data)
- [Fully Controlled Component](#fully-controlled-component)
- [Functional Rendering](#functional-rendering)
- [Multi-Sort](#multi-sort)
- [Filtering](#filtering)
- [Component Overrides](#component-overrides)
- [Contributing](#contributing)
- [Scripts](#scripts)
- [Used By](#used-by)
## Installation
@@ -105,16 +122,19 @@ import 'react-table/react-table.css'
##### CDN
```html
<!-- CSS -->
<link rel="stylesheet" href="https://unpkg.com/react-table@latest/react-table.css">
<!-- CSS -->
<link
rel="stylesheet"
href="https://unpkg.com/react-table@latest/react-table.css"
/>
<!-- JS -->
<script src="https://unpkg.com/react-table@latest/react-table.js"></script>
<script src="https://unpkg.com/react-table@latest/react-table.min.js"></script>
<!-- JS -->
<script src="https://unpkg.com/react-table@latest/react-table.js"></script>
<script src="https://unpkg.com/react-table@latest/react-table.min.js"></script>
<script>
var ReactTable = window.ReactTable.default
</script>
<script>
var ReactTable = window.ReactTable.default;
</script>
```
## Example
@@ -150,7 +170,7 @@ render() {
accessor: 'friend.age'
}]
<ReactTable
return <ReactTable
data={data}
columns={columns}
/>
@@ -161,6 +181,21 @@ render() {
Simply pass the `data` prop anything that resembles an array or object. Client-side sorting and pagination are built in, and your table will update gracefully as you change any props. [Server-side data](#server-side-data) is also supported!
```javascript
<ReactTable
data={[...]}
/>
```
**Pro Tip: Using the `resolveData` prop** - Any time the `data` prop value changes (using a `===` comparison), the table will update, but sometimes you need to materialize, alter, or shape this data before it enters the table. To do this, you can use the `resolveData` prop! It recieves the `data` prop as the only parameter and returns the resolved data.
```javascript
<ReactTable
data={myData} // The data prop should be immutable and only change when you want to update the table
resolveData={data => data.map(row => row)} // But you can break immutability here because `resolveData` runs when the `data` prop changes!
/>
```
## Props
These are all of the available props (and their default values) for the main `<ReactTable />` component.
@@ -169,6 +204,7 @@ These are all of the available props (and their default values) for the main `<R
{
// General
data: [],
resolveData: data => resolvedData,
loading: false,
showPagination: true,
showPaginationTop: false,
@@ -198,11 +234,11 @@ These are all of the available props (and their default values) for the main `<R
},
defaultSortMethod: (a, b, desc) => {
// force null and undefined to the bottom
a = (a === null || a === undefined) ? -Infinity : a
b = (b === null || b === undefined) ? -Infinity : b
a = a === null || a === undefined ? '' : a
b = b === null || b === undefined ? '' : b
// force any string values to lowercase
a = a === 'string' ? a.toLowerCase() : a
b = b === 'string' ? b.toLowerCase() : b
a = typeof a === 'string' ? a.toLowerCase() : a
b = typeof b === 'string' ? b.toLowerCase() : b
// Return either 1 or -1 to indicate a sort priority
if (a > b) {
return 1
@@ -210,7 +246,8 @@ These are all of the available props (and their default values) for the main `<R
if (a < b) {
return -1
}
// returning 0, undefined or any falsey value will use subsequent sorts or the index as a tiebreaker
// returning 0, undefined or any falsey value will use subsequent sorts or
// the index as a tiebreaker
return 0
},
PadRowComponent: () => <span>&nbsp;</span>, // the content rendered inside of a padding row
@@ -276,7 +313,21 @@ These are all of the available props (and their default values) for the main `<R
getNoDataProps: () => ({}),
getResizerProps: () => ({}),
// Custom pagination rendering
renderPageJump: ({ onChange, value, onBlur, onKeyPress, inputType, pageJumpText }) => component,
renderCurrentPage: page => component,
renderTotalPagesCount: pages => component,
renderPageSizeOptions: ({
pageSize,
pageSizeOptions,
rowsSelectorText,
onPageSizeChange,
rowsText,
}) => component
// Global Column Defaults
// To override only some values, import { ReactTableDefaults } from 'react-table'
// and construct your overrides (e.g. {...ReactTableDefaults.column, className: 'react-table-cell'})
column: {
// Renderers
Cell: undefined,
@@ -312,6 +363,8 @@ These are all of the available props (and their default values) for the main `<R
},
// Global Expander Column Defaults
// To override only some values, import { ReactTableDefaults } from 'react-table'
// and construct your overrides (e.g. {...ReactTableDefaults.expanderDefaults, sortable: true})
expanderDefaults: {
sortable: false,
resizable: false,
@@ -330,6 +383,10 @@ These are all of the available props (and their default values) for the main `<R
pageText: 'Page',
ofText: 'of',
rowsText: 'rows',
// Accessibility Labels
pageJumpText: 'jump to page',
rowsSelectorText: 'rows per page',
}
```
@@ -429,21 +486,21 @@ Or just define them as props
React Table supports very flexible renderers for just about everything:
* `Cell` - Renders a standard cell
* `Header` - Renders a column header or column group header
* `Footer` - Renders a column footer
* `Filter` - Renders a column's filter UI
* `Aggregated` - Renders an aggregated cell
* `Pivot` - Renders a pivoted cell (by default, will utilize `Expander` and `PivotValue` renderers)
* `PivotValue` - Renders the value inside a `Pivot` renderer
* `Expander` - Renders the Expander used in both the default `Pivot` renderer and any expander-designated column
- `Cell` - Renders a standard cell
- `Header` - Renders a column header or column group header
- `Footer` - Renders a column footer
- `Filter` - Renders a column's filter UI
- `Aggregated` - Renders an aggregated cell
- `Pivot` - Renders a pivoted cell (by default, will utilize `Expander` and `PivotValue` renderers)
- `PivotValue` - Renders the value inside a `Pivot` renderer
- `Expander` - Renders the Expander used in both the default `Pivot` renderer and any expander-designated column
Any of these renderers can be one of the following:
* A React Class
* JSX or any rendered react component
* Stateless functional component
* Function that returns any primitive
- A React Class
- JSX or any rendered react component
- Stateless functional component
- Function that returns any primitive
All of these formats receive the following props:
@@ -452,7 +509,7 @@ All of these formats receive the following props:
// Row-level props
row: Object, // the materialized row of data
original: , // the original row of data
index: '', // the index of the row in the original arra
index: '', // the index of the row in the original array
viewIndex: '', // the index of the row relative to the current view
level: '', // the nesting level of this row
nestingPath: '', // the nesting path of this row
@@ -485,14 +542,14 @@ Any values that contain a dot (`.`) will be split.
Any values that contain bracket (`[]`) will be split.
This array is then used as the path to the value to return.
("$" is the placeholder value that would be returned by the default accessor)
("\$" is the placeholder value that would be returned by the default accessor)
| value | path | data |
| ------------ | --------------- | ---------------------- |
| "a" | ["a"] | {"a": $} |
| "a.b" | ["a", "b"] | {"a": {"b": $}} |
| "a[0]" | ["a", "0"] | {"a": [$]} |
| ["a.b", "c"] | ["a", "b", "c"] | {"a": {"b": {"c": $}}} |
| value | path | data |
| ------------ | --------------- | ----------------------- |
| "a" | ["a"] | {"a": \$} |
| "a.b" | ["a", "b"] | {"a": {"b": \$}} |
| "a[0]" | ["a", "0"] | {"a": [$]} |
| ["a.b", "c"] | ["a", "b", "c"] | {"a": {"b": {"c": \$}}} |
_NOTE_
If your data has a field/key with a dot (`.`) you will need to supply a custom accessor.
@@ -522,14 +579,14 @@ const columns = [{
You can use any react component or JSX to display content in column headers, cells and footers. Any component you use will be passed the following props (if available):
* `row` - Original row from your data
* `original` - The post-accessed values from the original row
* `index` - The index of the row
* `viewIndex` - the index of the row relative to the current page
* `level` - The nesting depth (zero-indexed)
* `nestingPath` - The nesting path of the row
* `aggregated` - A boolean stating if the row is an aggregation row
* `subRows` - An array of any expandable sub-rows contained in this row
- `row` - Original row from your data
- `original` - The post-accessed values from the original row
- `index` - The index of the row
- `viewIndex` - the index of the row relative to the current page
- `level` - The nesting depth (zero-indexed)
- `nestingPath` - The nesting path of the row
- `aggregated` - A boolean stating if the row is an aggregation row
- `subRows` - An array of any expandable sub-rows contained in this row
```javascript
// This column uses a stateless component to produce a different colored bar depending on the value
@@ -559,8 +616,8 @@ const columns = [
row.value > 66
? "#85cc00"
: row.value > 33
? "#ffbf00"
: "#ff2e00",
? "#ffbf00"
: "#ff2e00",
borderRadius: "2px",
transition: "all .2s ease-out"
}}
@@ -573,14 +630,14 @@ const columns = [
## Styles
* React-table ships with a minimal and clean stylesheet to get you on your feet quickly.
* The stylesheet is located at `react-table/react-table.css`.
* There are countless ways to import a stylesheet. If you have questions on how to do so, consult the documentation of your build system.
- React-table ships with a minimal and clean stylesheet to get you on your feet quickly.
- The stylesheet is located at `react-table/react-table.css`.
- There are countless ways to import a stylesheet. If you have questions on how to do so, consult the documentation of your build system.
#### Classes
* Adding a `-striped` className to ReactTable will slightly color odd numbered rows for legibility
* Adding a `-highlight` className to ReactTable will highlight any row as you hover over it
- Adding a `-striped` className to ReactTable will slightly color odd numbered rows for legibility
- Adding a `-highlight` className to ReactTable will highlight any row as you hover over it
#### CSS
@@ -606,6 +663,9 @@ Every single built-in component's props can be dynamically extended using any on
getTheadProps={fn}
getTheadTrProps={fn}
getTheadThProps={fn}
getTheadFilterProps={fn}
getTheadFilterTrProps={fn}
getTheadFilterThProps={fn}
getTbodyProps={fn}
getTrGroupProps={fn}
getTrProps={fn}
@@ -763,7 +823,7 @@ If you want to handle pagination, sorting, and filtering on the server, `react-t
1. Feed React Table `data` from somewhere dynamic. eg. `state`, a redux store, etc...
1. Add `manual` as a prop. This informs React Table that you'll be handling sorting and pagination server-side
1. Subscribe to the `onFetchData` prop. This function is called at `compomentDidMount` and any time sorting, pagination or filterting is changed in the table
1. Subscribe to the `onFetchData` prop. This function is called at `componentDidMount` and any time sorting, pagination or filterting is changed in the table
1. In the `onFetchData` callback, request your data using the provided information in the params of the function (current state and instance)
1. Update your data with the rows to be displayed
1. Optionally set how many pages there are total
@@ -797,7 +857,7 @@ If you want to handle pagination, sorting, and filtering on the server, `react-t
/>
```
For a detailed example, take a peek at our <a href="https://github.com/react-tools/react-table/blob/master/stories/ServerSide.js" target="\_parent">async table mockup</a>
For a detailed example, take a peek at our <a href="https://react-table.js.org/#/story/server-side-data" target="\_parent">async table mockup</a>
## Fully Controlled Component
@@ -839,7 +899,7 @@ Here are the props and their corresponding callbacks that control the state of t
onPageSizeChange={(pageSize, pageIndex) => {...}} // Called when the pageSize is changed by the user. The resolve page is also sent to maintain approximate position in the data
onSortedChange={(newSorted, column, shiftKey) => {...}} // Called when a sortable column header is clicked with the column itself and if the shiftkey was held. If the column is a pivoted column, `column` will be an array of columns
onExpandedChange={(newExpanded, index, event) => {...}} // Called when an expander is clicked. Use this to manage `expanded`
onFilteredChange={(column, value) => {...}} // Called when a user enters a value into a filter input field or the value passed to the onFiltersChange handler by the Filter option.
onFilteredChange={(filtered, column) => {...}} // Called when a user enters a value into a filter input field or the value passed to the onFiltersChange handler by the Filter option.
onResizedChange={(newResized, event) => {...}} // Called when a user clicks on a resizing component (the right edge of a column header)
/>
```
@@ -850,15 +910,15 @@ Possibly one of the coolest features of React-Table is its ability to expose int
The function you pass will be called with the following items:
* Fully-resolved state of the table
* A function that returns the standard table component
* The instance of the component
- Fully-resolved state of the table
- A function that returns the standard table component
- The instance of the component
You can then return any JSX or react you want! This turns out to be perfect for:
* Accessing the internal state of the table without a `ref`
* Decorating the table or extending it with your own UI
* Building your own custom display logic
- Accessing the internal state of the table without a `ref`
- Decorating the table or extending it with your own UI
- Building your own custom display logic
Accessing internal state and wrapping with more UI:
@@ -893,10 +953,10 @@ The possibilities are endless!
Sorting comes built in with React-Table.
* Click a column header to sort by its accessor.
* Click it again to reverse the sort.
* Set `defaultSortDesc` property to `true` to make the first sort direction default to descending.
* Override a specific column's default sort direction by using the same `defaultSortDesc` property on a column, set to `true`
- Click a column header to sort by its accessor.
- Click it again to reverse the sort.
- Set `defaultSortDesc` property to `true` to make the first sort direction default to descending.
- Override a specific column's default sort direction by using the same `defaultSortDesc` property on a column, set to `true`
## Multi-Sort
@@ -913,9 +973,9 @@ To override the sorting algorithm for a single column, use the `sortMethod` colu
Supply a function that implements the native javascript [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) interface. This is React Table's default sorting algorithm:
* `a` the first value to compare
* `b` the second value to compare
* `desc` true if sort is descending, false if ascending
- `a` the first value to compare
- `b` the second value to compare
- `desc` true if sort is descending, false if ascending
```javascript
defaultSortMethod = (a, b, desc) => {
@@ -999,19 +1059,19 @@ If you choose to change the core components React-Table uses to render, you must
To suggest a feature, create an issue if it does not already exist.
If you would like to help develop a suggested feature follow these steps:
* Fork this repo
* Install dependencies with `$ yarn`
* Auto-build files as you edit with `$ yarn run watch`
* Implement your changes to files in the `src/` directory
* Run the <a href="https://github.com/tannerlinsley/react-story">React Story</a> locally with `$ yarn run docs`
* View changes as you edit `docs/src`
* Submit PR for review
- Fork this repo
- Install dependencies with `$ yarn`
- Auto-build files as you edit with `$ yarn run watch`
- Implement your changes to files in the `src/` directory
- Run the <a href="https://github.com/tannerlinsley/react-story">React Story</a> locally with `$ yarn run docs`
- View changes as you edit `docs/src`
- Submit PR for review
#### Scripts
* `$ yarn run watch` Watches files and builds via babel
* `$ yarn run docs` Runs the storybook server
* `$ yarn run test` Runs the test suite
- `$ yarn run watch` Watches files and builds via babel
- `$ yarn run docs` Runs the storybook server
- `$ yarn run test` Runs the test suite
## Used By
+55 -52
View File
@@ -1,69 +1,72 @@
/* eslint-disable */
import React from "react";
import React from 'react';
//
import ReactStory, { defaultProps } from "react-story";
import CodeSandbox from "./CodeSandbox.js";
import "./stories/utils/prism.css";
import "../../react-table.css";
import ReactStory, { defaultProps } from 'react-story';
import CodeSandbox from './CodeSandbox.js';
import './stories/utils/prism.css';
import '../../react-table.css';
import Readme from "./stories/Readme.js";
import HOCReadme from "./stories/HOCReadme.js";
import Readme from './stories/Readme.js';
import HOCReadme from './stories/HOCReadme.js';
// import Test from './stories/test.js'
// import Tester from './examples/expander';
const stories = [
{ name: "Readme", component: Readme },
{ name: "HOC Readme", component: HOCReadme },
{ name: 'Readme', component: Readme },
{ name: 'HOC Readme', component: HOCReadme },
// { name: 'Tester', component: Test },
{ name: "Simple Table", component: CodeSandbox("X6npLXPRW") },
{ name: 'Simple Table', component: CodeSandbox('X6npLXPRW') },
{
name: "Cell Renderers & Custom Components",
component: CodeSandbox("OyRL04Z4Y")
name: 'Cell Renderers & Custom Components',
component: CodeSandbox('OyRL04Z4Y')
},
{ name: "Default Sorting", component: CodeSandbox("gLwmmjzA3") },
{ name: 'Default Sorting', component: CodeSandbox('gLwmmjzA3') },
{
name: "Custom Sorting",
component: CodeSandbox("VGx67J35")
name: 'Custom Sorting',
component: CodeSandbox('VGx67J35')
},
{ name: "Custom Column Widths", component: CodeSandbox("o2OORXNXN") },
{ name: "Custom Component Props", component: CodeSandbox("nZW3L0wp4") },
{ name: "Server-side Data", component: CodeSandbox("wjrn8wy3R") },
{ name: "Sub Components", component: CodeSandbox("n2gqAxl7") },
{ name: "Pivoting & Aggregation", component: CodeSandbox("oNY9z8xN") },
{ name: 'Custom Column Widths', component: CodeSandbox('o2OORXNXN') },
{ name: 'Custom Component Props', component: CodeSandbox('nZW3L0wp4') },
{ name: 'Server-side Data', component: CodeSandbox('wjrn8wy3R') },
{ name: 'Sub Components', component: CodeSandbox('n2gqAxl7') },
{ name: 'Pivoting & Aggregation', component: CodeSandbox('oNY9z8xN') },
{
name: "Pivoting & Aggregation w/ Sub Components",
component: CodeSandbox("p0kEVBgQ")
name: 'Pivoting & Aggregation w/ Sub Components',
component: CodeSandbox('p0kEVBgQ')
},
{
name: "100k Rows w/ Pivoting & Sub Components",
component: CodeSandbox("DRmKj0XyK")
name: '100k Rows w/ Pivoting & Sub Components',
component: CodeSandbox('DRmKj0XyK')
},
{ name: "Pivoting Options", component: CodeSandbox("kZKmNBK6r") },
{ name: "Functional Rendering", component: CodeSandbox("VPZ0Bzv8X") },
{ name: 'Pivoting Options', component: CodeSandbox('kZKmNBK6r') },
{ name: 'Functional Rendering', component: CodeSandbox('VPZ0Bzv8X') },
{
name: "Custom Expander Position",
component: CodeSandbox("1jj2XrPEV")
name: 'Custom Expander Position',
component: CodeSandbox('1jj2XrPEV')
},
{ name: 'Custom "No Data" Text', component: CodeSandbox("RgRpRDv80") },
{ name: "Footers", component: CodeSandbox("KOqQXn3p8") },
{ name: "Custom Filtering", component: CodeSandbox("5Eyxxxyx") },
{ name: "Controlled Component", component: CodeSandbox("r7XEZRK2") },
{ name: "Editable Table", component: CodeSandbox("n5r19gzQP") },
{ name: 'Custom "No Data" Text', component: CodeSandbox('RgRpRDv80') },
{ name: 'Footers', component: CodeSandbox('KOqQXn3p8') },
{ name: 'Custom Filtering', component: CodeSandbox('5Eyxxxyx') },
{ name: 'Controlled Component', component: CodeSandbox('r7XEZRK2') },
{ name: 'Editable Table', component: CodeSandbox('n5r19gzQP') },
{
name: "Fixed Header w/ Vertical Scroll",
component: CodeSandbox("7LY0gjA8O")
name: 'Fixed Header w/ Vertical Scroll',
component: CodeSandbox('7LY0gjA8O')
},
{
name: "Multiple Pagers (Top and Bottom)",
component: CodeSandbox("VEZ8OgvX")
name: 'Multiple Pagers (Top and Bottom)',
component: CodeSandbox('VEZ8OgvX')
},
{ name: "Tree Table (HOC)", component: CodeSandbox("lxmr4wynzq") },
{ name: "Select Table (HOC)", component: CodeSandbox("7yq5ylw09j") },
{ name: "Select Tree Table (HOC)", component: CodeSandbox("2p7jp4klwp") }
{ name: 'Tree Table (HOC)', component: CodeSandbox('lxmr4wynzq') },
{ name: 'Select Table (HOC)', component: CodeSandbox('7yq5ylw09j') },
{ name: 'Select Tree Table (HOC)', component: CodeSandbox('2p7jp4klwp') },
{ name: 'Foldable Table (HOC)', component: CodeSandbox('8pkrj5yorl') },
{ name: 'Advanced Expand Table (HOC)', component: CodeSandbox('y2m39jz8v1') }
];
export default class App extends React.Component {
@@ -71,41 +74,41 @@ export default class App extends React.Component {
return (
<ReactStory
style={{
display: "block",
width: "100%",
height: "100%"
display: 'block',
width: '100%',
height: '100%'
}}
pathPrefix="story/"
StoryWrapper={props => (
<defaultProps.StoryWrapper
css={{
padding: 0,
display: "flex",
flexDirection: "column"
display: 'flex',
flexDirection: 'column'
}}
>
<a
href="//github.com/react-tools/react-table"
style={{
display: "block",
textAlign: "center",
borderBottom: "solid 3px #cccccc"
display: 'block',
textAlign: 'center',
borderBottom: 'solid 3px #cccccc'
}}
>
<img
src="https://github.com/react-tools/media/raw/master/logo-react-table.png"
alt="React Table Logo"
style={{
width: "150px",
padding: "10px"
width: '150px',
padding: '10px'
}}
/>
</a>
<div
{...props}
style={{
flex: "1 0 auto",
position: "relative"
flex: '1 0 auto',
position: 'relative'
}}
/>
</defaultProps.StoryWrapper>
@@ -0,0 +1,116 @@
import React from 'react';
import { render } from 'react-dom';
import { makeData, Logo, Tips } from './Utils';
import { advancedExpandTableHOC } from '../../../../lib/hoc/advancedExpandTable';
// Import React Table
import ReactTable from 'react-table';
import 'react-table/react-table.css';
const columns = [
{
Header: 'First Name',
accessor: 'firstName',
Cell: props => {
const {
// react table props
columnProps: { rest: { showRowSubComponent } },
nestingPath
} = props;
return (
<div>
<button
onClick={e => showRowSubComponent({ nestingPath: nestingPath }, e)}
>
SHOW SUBCOMPONENT {props.value}
</button>
</div>
);
}
},
{
Header: 'Last Name',
id: 'lastName',
accessor: d => d.lastName
},
{
Header: 'Info',
columns: [
{
Header: 'Age',
accessor: 'age',
Cell: props => {
const {
// react table props
columnProps: { rest: { toggleRowSubComponent } },
nestingPath
} = props;
return (
<div>
<button
onClick={e =>
toggleRowSubComponent({ nestingPath: nestingPath }, e)
}
>
TOGGLE SUBCOMPONENT {props.value}
</button>
</div>
);
}
},
{
Header: 'Status',
accessor: 'status'
}
]
},
{
Header: 'Stats',
columns: [
{
Header: 'Visits',
accessor: 'visits'
}
]
}
];
const AdvancedExpandReactTable = advancedExpandTableHOC(ReactTable);
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
data: makeData()
};
}
render() {
const { data } = this.state;
return (
<div>
<AdvancedExpandReactTable
data={data}
columns={columns}
defaultPageSize={10}
className='-striped -highlight'
SubComponent={({ row, nestingPath, toggleRowSubComponent }) => {
return (
<div style={{ padding: '20px' }}>
<button
onClick={e => toggleRowSubComponent({ nestingPath }, e)}
>
CLOSE SUBCOMPONENT {row.firstName} {row.lastName}
</button>
</div>
);
}}
/>
<br />
<Tips />
<Logo />
</div>
);
}
}
render(<App />, document.getElementById('root'));
+1 -1
View File
@@ -47,7 +47,7 @@ export default class ComponentTest extends React.component {
// const rtProps = {
// data,
// columns,
// // ExpanderComponent: (props)=><ExpanderComponent {...props} />,
// // ExpanderComponent: (props, closeExpanded)=><ExpanderComponent {...props, closeExpanded} />,
// // SubComponent: (props)=><SubComponent {...props} />,
// // multiSort: false,
// }
@@ -0,0 +1,110 @@
import React from 'react'
import ReactTable from '../../../../lib/index'
import FoldableTableHOC from '../../../../lib/hoc/foldableTable'
import selectTableHOC from '../../../../lib/hoc/selectTable'
const FoldableTable = FoldableTableHOC(selectTableHOC(ReactTable))
export default class FoldableTableCustomState extends React.Component {
constructor(props, context) {
super(props, context)
this.state = { folded: {}, seleted: {}, selectedAll: false }
}
getData = () => [{
id: 1,
first_name: 'Jeanette',
'last_name': 'Penddreth',
email: 'jpenddreth0@census.gov',
'gender': 'Female',
ip_address: '26.58.193.2',
}, {
'id': 2,
'first_name': 'Giavani',
last_name: 'Frediani',
'email': 'gfrediani1@senate.gov',
'gender': 'Male',
'ip_address': '229.179.4.212',
}, {
'id': 3,
first_name: 'Noell',
last_name: 'Bea',
'email': 'nbea2@imageshack.us',
gender: 'Female',
ip_address: '180.66.162.255',
}, {
'id': 4,
'first_name': 'Willard',
'last_name': 'Valek',
email: 'wvalek3@vk.com',
'gender': 'Male',
ip_address: '67.76.188.26',
}];
toggleSelection = (key, shift, row) => {
const { selected } = this.state
let newSelected = Object.assign({}, selected)
newSelected[key] = !newSelected[key]
this.setState(p => ({ selected: newSelected }))
};
toggleAll = () => {
const { selectedAll } = this.state
if (selectedAll) { this.setState(p => { return { selectedAll: false, seleted: {} } }); }
else {
const data = this.getData()
let newSelected = {}
data.forEach(d => newSelected[d.id] = true)
this.setState(p => ({ selectedAll: true, seleted: newSelected }))
}
}
isSelected = key => this.state.seleted[key];
render() {
return (<FoldableTable
//SelectTable props
keyField='id'
toggleSelection={this.toggleSelection}
toggleAll={this.toggleAll}
isSelected={this.isSelected}
selectAll={this.state.selectedAll}
selectType='checkbox'
onFoldChange={newFolded => this.setState(p => { return { folded: newFolded } })}
folded={this.state.folded}
data={this.getData()}
columns={[{
Header: "Name",
foldable: true,
columns: [
{
Header: "First Name",
accessor: "first_name"
},
{
Header: "Last Name",
accessor: "last_name"
}
]
}, {
Header: "Info",
foldable: true,
columns: [
{
Header: "Email",
accessor: "email"
},
{
Header: "Gender",
accessor: "gender"
}
]
}]
}></FoldableTable>)
}
}
@@ -0,0 +1,71 @@
import React from 'react'
import ReactTable from '../../../../lib/index'
import FoldableTableHOC from '../../../../lib/hoc/foldableTable'
const FoldableTable = FoldableTableHOC(ReactTable)
export default class FoldableTableWithHeader extends React.Component {
getData = () => [{
id: 1,
first_name: 'Jeanette',
last_name: 'Penddreth',
'email': 'jpenddreth0@census.gov',
gender: 'Female',
'ip_address': '26.58.193.2',
}, {
'id': 2,
first_name: 'Giavani',
last_name: 'Frediani',
email: 'gfrediani1@senate.gov',
gender: 'Male',
'ip_address': '229.179.4.212',
}, {
'id': 3,
'first_name': 'Noell',
last_name: 'Bea',
'email': 'nbea2@imageshack.us',
'gender': 'Female',
ip_address: '180.66.162.255',
}, {
'id': 4,
'first_name': 'Willard',
'last_name': 'Valek',
email: 'wvalek3@vk.com',
'gender': 'Male',
ip_address: '67.76.188.26',
}];
render() {
return (<FoldableTable
data={this.getData()}
columns={[{
Header: "Name",
foldable: true,
columns: [
{
Header: "First Name",
accessor: "first_name"
},
{
Header: "Last Name",
accessor: "last_name"
}
]
}, {
Header: "Info",
foldable: true,
columns: [
{
Header: "Email",
accessor: "email"
},
{
Header: "Gender",
accessor: "gender"
}
]
}]
}></FoldableTable>)
}
}
@@ -0,0 +1,64 @@
import React from 'react';
import ReactTable from '../../../../lib/index';
import FoldableTableHOC from '../../../../lib/hoc/foldableTable';
const FoldableTable = FoldableTableHOC(ReactTable);
export default class FoldableTableWithoutHeader extends React.Component {
getData = () => [{
"id": 1,
"first_name": "Jeanette",
"last_name": "Penddreth",
"email": "jpenddreth0@census.gov",
"gender": "Female",
"ip_address": "26.58.193.2"
}, {
"id": 2,
"first_name": "Giavani",
"last_name": "Frediani",
"email": "gfrediani1@senate.gov",
"gender": "Male",
"ip_address": "229.179.4.212"
}, {
"id": 3,
"first_name": "Noell",
"last_name": "Bea",
"email": "nbea2@imageshack.us",
"gender": "Female",
"ip_address": "180.66.162.255"
}, {
"id": 4,
"first_name": "Willard",
"last_name": "Valek",
"email": "wvalek3@vk.com",
"gender": "Male",
"ip_address": "67.76.188.26"
}];
render() {
return <FoldableTable
data={this.getData()}
columns={[
{
Header: "First Name",
accessor: "first_name"
},
{
Header: "Last Name",
accessor: "last_name",
foldable: true,
},
{
Header: "Email",
accessor: "email",
foldable: true,
},
{
Header: "Gender",
accessor: "gender",
foldable: true,
}
]}></FoldableTable>
}
}
+30
View File
@@ -0,0 +1,30 @@
import React from 'react'
import '../../../../react-table.css'
import FoldableTableWithHeader from './FoldableTableWithHeader'
import FoldableTableWithoutHeader from './FoldableTableWithoutHeader'
import FoldableTableCustomState from './FoldableTableCustomState'
class FaldableComponentTest extends React.Component {
render() {
return (
<div>
<p>- Sample With Header Columns</p>
<br />
<FoldableTableWithHeader />
<br /> <br />
<p>- Sample With Normal Columns</p>
<br />
<FoldableTableWithoutHeader />
<br /> <br />
<p>- Custom State and selectedTable</p>
<br />
<FoldableTableCustomState />
</div >
)
}
}
export default FaldableComponentTest
+10 -4
View File
@@ -1,7 +1,13 @@
/* eslint-disable */
import TreeTable from "./treetable";
import SelectTable from "./selecttable";
import SelectTreeTable from "./selecttreetable";
import TreeTable from './treetable'
import SelectTable from './selecttable'
import SelectTreeTable from './selecttreetable'
import FoldableTable from './foldabletable';
export { TreeTable, SelectTable, SelectTreeTable };
export {
TreeTable,
SelectTable,
SelectTreeTable,
FoldableTable
}

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

+8348
View File
File diff suppressed because it is too large Load Diff
+11 -8
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "6.8.2",
"version": "6.9.0",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/react-tools/react-table#readme",
@@ -26,10 +26,10 @@
"media/*.png"
],
"scripts": {
"build:cjs": "babel src --out-dir lib --source-maps inline",
"build:es": "BABEL_ENV=es babel src --out-dir es --source-maps inline",
"build:umd": "BABEL_ENV=umd rollup -c",
"build:umd-min": "BABEL_ENV=umd NODE_ENV=production rollup -c",
"build:cjs": "babel src --out-dir lib --source-maps inline --copy-files",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --source-maps inline",
"build:umd": "cross-env BABEL_ENV=umd rollup -c",
"build:umd-min": "cross-env BABEL_ENV=umd NODE_ENV=production rollup -c",
"build:css": "rimraf react-table.css && stylus src/index.styl --compress -o react-table.css && yarn css:autoprefix",
"css:autoprefix": "postcss --use autoprefixer react-table.css -r",
"watch": "npm-run-all --parallel watch:*",
@@ -46,7 +46,9 @@
"classnames": "^2.2.5"
},
"peerDependencies": {
"react": "^15.x.x || ^16.x.x"
"prop-types": "^15.5.0",
"react": "^15.x.x || ^16.x.x",
"react-dom": "^15.x.x || ^16.x.x"
},
"devDependencies": {
"autoprefixer": "^6.7.0",
@@ -57,6 +59,7 @@
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.1.4",
"eslint": "^4.1.1",
"eslint-config-react-tools": "^1.0.10",
"eslint-plugin-class-property": "^1.0.6",
@@ -68,8 +71,8 @@
"onchange": "^3.0.2",
"postcss-cli": "^2.6.0",
"prop-types": "^15.6.0",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-json-tree": "^0.10.9",
"rimraf": "^2.6.1",
"rollup": "^0.55.3",
+8 -1
View File
@@ -9,12 +9,14 @@ const emptyObj = () => ({})
export default {
// General
data: [],
resolveData: data => data,
loading: false,
showPagination: true,
showPaginationTop: false,
showPaginationBottom: true,
showPageSizeOptions: true,
pageSizeOptions: [5, 10, 20, 25, 50, 100],
defaultPage: 0,
defaultPageSize: 20,
showPageJump: true,
collapseOnSortingChange: true,
@@ -126,12 +128,14 @@ export default {
PivotValue: undefined,
Expander: undefined,
Filter: undefined,
Placeholder: undefined,
// All Columns
sortable: undefined, // use table default
resizable: undefined, // use table default
filterable: undefined, // use table default
show: true,
minWidth: 100,
minResizeWidth: 11,
// Cells only
className: '',
style: {},
@@ -171,6 +175,8 @@ export default {
pageText: 'Page',
ofText: 'of',
rowsText: 'rows',
pageJumpText: 'jump to page',
rowsSelectorText: 'rows per page',
// Components
TableComponent: ({ children, className, ...rest }) => (
@@ -217,12 +223,13 @@ export default {
</div>
),
TfootComponent: _.makeTemplateComponent('rt-tfoot', 'Tfoot'),
FilterComponent: ({ filter, onChange }) => (
FilterComponent: ({ filter, onChange, column }) => (
<input
type="text"
style={{
width: '100%',
}}
placeholder={column.Placeholder}
value={filter ? filter.value : ''}
onChange={event => onChange(event.target.value)}
/>
+182 -5
View File
@@ -36,6 +36,17 @@ But there is more documentation on the `select` HOC below.
## Currently Available HOCs
Any of the below HOCs can be imported from react-table like so:
```javascript
import ReactTable from "react-table";
import treeTableHOC from "react-table/lib/hoc/treeTable";
const TreeTable = treeTableHOC(ReactTable);
```
Swap `treeTable` and `TreeTable` with any of the other HOC names as necessary.
### TreeTable
TreeTable takes over the rendering of the generated pivot rows of ReactTable so that they appear more like an expandable Tree.
@@ -45,9 +56,6 @@ It accomplishes this by rendering a 100% wide div and then only rendering the ce
Using it is as simple as doing the following:
```javascript
import ReactTable from "react-table";
import treeTableHOC from "react-table/lib/hoc/treeTable";
const TreeTable = treeTableHOC(ReactTable);
```
@@ -71,7 +79,7 @@ You include the HOC in the same manner as you would for the treeTableHOC but the
**Note:** The select field defaults to the accessor `_id` property in order to render the select field for that particular row. If your objects have different
unique ID fields, make sure to tell React Table that by passing it the `keyField` property.
```Javascript
```javascript
<ReactTable keyField='id' />
```
@@ -96,13 +104,182 @@ SelectTreeTable is a combination of TreeTable and SelectTable.
To function correctly the chain has to be in the correct order as follows (see the comments in the guid on HOCs below).
```Javascript
```javascript
const SelectTreeTable = selectTableHOC(treeTableHOC(ReactTable));
```
In this particular instance it is (probably) because the functions need access to the state on the wrapped component to manage
the selected items. Although that is not totally clearly the issue.
### FoldableTable
FoldableTable is a HOC that make the columns are foldable. The reason I developed this HOC because when working on the real project related to the financial which display so many columns for validation and comparison.
So foldable columns allow users to temporary hidden the unwanted to columns so that they can focus on the data that they want to see.
#### How it works
```javascript
const FoldableTable = FoldableTableHOC(ReactTable);
```
It will scan all the columns which `foldable` is `true` and apply the foldable column feature. This feature will work for both normal columns and header columns as samples below.
- With Header Columns
```javascript
render(){
return <FoldableTable
columns={[{
Header: "Name",
foldable: true,
columns: [{
Header: "First Name",
accessor: "first_name"
},{
Header: "Last Name",
accessor: "last_name"
}]
},{
Header: "Info",
foldable: true,
columns: [{
Header: "Email",
accessor: "email"
},{
Header: "Gender",
accessor: "gender"
}]
}]
}/>
}
```
![With Header Columns](https://raw.githubusercontent.com/baoduy/Images/master/Wordpress/JavaScripts/react-table%20foldableHOC/FoldableTable%20With%20Header.gif)
- With Nornal Columns
```javascript
render() {
return <FoldableTable
columns={[{
Header: "First Name",
accessor: "first_name"
},
{
Header: "Last Name",
accessor: "last_name",
foldable: true,
},
{
Header: "Email",
accessor: "email",
foldable: true,
},
{
Header: "Gender",
accessor: "gender",
foldable: true,
}]}></FoldableTable>
}
```
![With Normal Columns](https://raw.githubusercontent.com/baoduy/Images/master/Wordpress/JavaScripts/react-table%20foldableHOC/FoldableTable%20Without%20Header.gif)
- The `FoldableTable` also fully compatible with existing HOCs, below is with selectTableHOC.
![With Normal Columns](https://raw.githubusercontent.com/baoduy/Images/master/Wordpress/JavaScripts/react-table%20foldableHOC/FoldableTable%20With%20selectTable.gif)
#### State management
If you would like to manage the state of FoldableTable, then add the following codes.
```javascript
render() {
return <FoldableTable
onFoldChange={newFolded => this.setState(p => { return { folded: newFolded } })}
folded={this.state.folded}
/>
}
```
#### Custom Components
- FoldIconComponent: to render the Icon of buttons.
- FoldButtonComponent: to render the folding buttons for each Column.
With default rendering as below.
```javascript
const defaultFoldIconComponent = ({ collapsed }) => {
//Render your Icon here
}
const defaultFoldButtonComponent = ({ header, collapsed, icon, onClick }) => {
//Render your button here.
}
```
### AdvancedExpandTable
HOC which allows any Cell in the row to toggle the row's
SubComponent (expand/collapse). Also allows the SubComponent to toggle itself. Technically supports toggling any row's SubComponent.
These are the expand functions available to any SubComponent or Column Cell:
```
toggleRowSubComponent
showRowSubComponent
hideRowSubComponent
```
They are available through the `props.columnProps.rest` object.
On any change to the props, the table will reset the expanded state.
Accepts a onExpandedChange callback to be called whenever the table expanded state changes
Note: only supports 1 level of nesting.
Example usage in a Column Cell Renderer:
```javascript
Cell: props => {
const {
value
columnProps: { rest: { showRowSubComponent } },
nestingPath
} = props;
return (
<div>
<button
onClick={e => showRowSubComponent(nestingPath, e)}
>
{value}
</button>
</div>
);
}
```
Example usage in the ReactTable SubComponent (toggle itself):
```javascript
const AdvancedExpandReactTable = advancedExpandTableHOC(ReactTable);
<AdvancedExpandReactTable>
...
SubComponent={({ row, nestingPath, toggleRowSubComponent }) => {
return (
<div>
<button
onClick={e => toggleRowSubComponent({ nestingPath }, e)}
>
{row.value}
</button>
</div>
);
}}
/>
```
Each Column Renderer (E.g. Cell ) gets the expand functions in its props and each SubComponent gets the expand functions in its props
Expand functions takes the `nestingPath` or `rowInfo` given to each
Column Renderer and SubComponent already by ReactTable.
## HOC Guide for ReactTable
There are a few rules required when writing a HOC for ReactTable (other than meeting the normal lint standards - which are
+199
View File
@@ -0,0 +1,199 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import set from 'lodash.set'
import get from 'lodash.get'
/*
AvancedExpandTableHOC for ReactTable
HOC which allows any Cell in the row to toggle the row's
SubComponent. Also allows the SubComponent to toggle itself.
Expand functions available to any SubComponent or Column Cell:
toggleRowSubComponent
showRowSubComponent
hideRowSubComponent
Each Column Renderer (E.g. Cell ) gets the expand functions in its props
And Each SubComponent gets the expand functions in its props
Expand functions takes the `rowInfo` given to each
Column Renderer and SubComponent already by ReactTable.
*/
export const subComponentWithToggle = (SubComponent, expandFuncs) => props => (
<SubComponent {...props} {...expandFuncs} />
)
// each cell in the column gets passed the function to toggle a sub component
export const columnsWithToggle = (columns, expandFuncs) =>
columns.map(column => {
if (column.columns) {
return {
...column,
columns: columnsWithToggle(column.columns, expandFuncs),
}
}
return {
...column,
getProps () {
return {
...expandFuncs,
}
},
}
})
export const advancedExpandTableHOC = TableComponent =>
class AdvancedExpandTable extends Component {
constructor (props) {
super(props)
this.state = {
expanded: {},
}
this.toggleRowSubComponent = this.toggleRowSubComponent.bind(this)
this.showRowSubComponent = this.showRowSubComponent.bind(this)
this.hideRowSubComponent = this.hideRowSubComponent.bind(this)
this.getTdProps = this.getTdProps.bind(this)
this.fireOnExpandedChange = this.fireOnExpandedChange.bind(this)
this.expandFuncs = {
toggleRowSubComponent: this.toggleRowSubComponent,
showRowSubComponent: this.showRowSubComponent,
hideRowSubComponent: this.hideRowSubComponent,
}
}
// after initial render if we get new
// data, columns, page changes, etc.
// we reset expanded state.
componentWillReceiveProps () {
this.setState({
expanded: {},
})
}
static propTypes = {
columns: PropTypes.array.isRequired,
SubComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element])
.isRequired,
onExpandedChange: PropTypes.func,
};
static defaultProps = {
onExpandedChange: null,
};
static DisplayName = 'AdvancedExpandTable';
// since we pass the expand functions to each Cell,
// we need to filter it out from being passed as an
// actual DOM attribute. See getProps in columnsWithToggle above.
static TdComponent ({
toggleRowSubComponent,
showRowSubComponent,
hideRowSubComponent,
...rest
}) {
return <TableComponent.defaultProps.TdComponent {...rest} />
}
fireOnExpandedChange (rowInfo, e) {
// fire callback once state has changed.
if (this.props.onExpandedChange) {
this.props.onExpandedChange(rowInfo, e)
}
}
resolveNewTableState (rowInfoOrNestingPath, e, expandType) {
// derive nestingPath if only rowInfo is passed
let nestingPath = rowInfoOrNestingPath
if (rowInfoOrNestingPath.nestingPath) {
nestingPath = rowInfoOrNestingPath.nestingPath
}
this.setState(
prevState => {
const isExpanded = get(prevState.expanded, nestingPath)
// since we do not support nested rows, a shallow clone is okay.
const newExpanded = { ...prevState.expanded }
switch (expandType) {
case 'show':
set(newExpanded, nestingPath, {})
break
case 'hide':
set(newExpanded, nestingPath, false)
break
default:
// toggle
set(newExpanded, nestingPath, isExpanded ? false : {})
}
return {
...prevState,
expanded: newExpanded,
}
},
() => this.fireOnExpandedChange(rowInfoOrNestingPath, e)
)
}
toggleRowSubComponent (rowInfo, e) {
this.resolveNewTableState(rowInfo, e)
}
showRowSubComponent (rowInfo, e) {
this.resolveNewTableState(rowInfo, e, 'show')
}
hideRowSubComponent (rowInfo, e) {
this.resolveNewTableState(rowInfo, e, 'hide')
}
getTdProps (tableState, rowInfo, column) {
const { expander } = column
if (!expander) {
// no overrides
return {}
}
return {
// only override onClick for column Td
onClick: e => {
this.toggleRowSubComponent(rowInfo, e)
},
}
}
getWrappedInstance () {
if (!this.wrappedInstance) { console.warn('AdvancedExpandTable - No wrapped instance') }
if (this.wrappedInstance.getWrappedInstance) {
return this.wrappedInstance.getWrappedInstance()
}
return this.wrappedInstance
}
render () {
const {
columns, SubComponent, onExpandedChange, ...rest
} = this.props
const wrappedColumns = columnsWithToggle(columns, this.expandFuncs)
const WrappedSubComponent = subComponentWithToggle(
SubComponent,
this.expandFuncs
)
return (
<TableComponent
{...rest}
columns={wrappedColumns}
expanded={this.state.expanded}
getTdProps={this.getTdProps}
SubComponent={WrappedSubComponent}
TdComponent={AdvancedExpandTable.TdComponent}
/>
)
}
}
+230
View File
@@ -0,0 +1,230 @@
/* eslint-disable */
import React from 'react'
import left from './left.svg'
import right from './right.svg'
const defaultFoldIconComponent = ({ collapsed }) => {
const style = { width: 25 }
if (collapsed) return <img src={right} style={style} alt="right" />
return <img src={left} style={style} alt="left" />
}
const defaultFoldButtonComponent = ({ header, collapsed, icon, onClick }) => {
const style = {
marginLeft: '0px',
marginTop: '-5px',
marginBottom: '-8px',
float: 'left',
cursor: 'pointer',
}
return (
<div>
<div style={style} onClick={onClick}>
{icon}
</div>
{!collapsed && <div>{header}</div>}
</div>
)
}
export default ReactTable => {
const wrapper = class RTFoldableTable extends React.Component {
constructor(props, context) {
super(props, context)
this.state = {
folded: props.onFoldChange ? undefined : {},
resized: props.resized || [],
}
}
componentWillReceiveProps(newProps) {
if (this.state.resized !== newProps.resized) {
this.setState(p => ({ resized: newProps.resized }))
}
}
onResizedChange = resized => {
const { onResizedChange } = this.props
if (onResizedChange) onResizedChange(resized)
else {
this.setState(p => ({ resized }))
}
}
removeResized = column => {
const { id } = column
if (!id) return
const { resized } = this.state
if (!resized) return
const rs = resized.find(r => r.id === id)
if (!rs) return
const newResized = resized.filter(r => r !== rs)
this.onResizedChange(newResized)
}
// this is so we can expose the underlying ReactTable.
getWrappedInstance = () => {
if (!this.wrappedInstance) console.warn('RTFoldableTable - No wrapped instance')
if (this.wrappedInstance.getWrappedInstance) return this.wrappedInstance.getWrappedInstance()
return this.wrappedInstance
}
getCopiedKey = key => {
const { foldableOriginalKey } = this.props
return `${foldableOriginalKey}${key}`
}
copyOriginals = column => {
const { FoldedColumn } = this.props
// Stop copy if the column already copied
if (column.original_Header) return
Object.keys(FoldedColumn).forEach(k => {
const copiedKey = this.getCopiedKey(k)
if (k === 'Cell') column[copiedKey] = column[k] ? column[k] : c => c.value
else column[copiedKey] = column[k]
})
// Copy sub Columns
if (column.columns && !column.original_Columns) column.original_Columns = column.columns
// Copy Header
if (!column.original_Header) column.original_Header = column.Header
}
restoreToOriginal = column => {
const { FoldedColumn } = this.props
Object.keys(FoldedColumn).forEach(k => {
// ignore header as handling by foldableHeaderRender
if (k === 'Header') return
const copiedKey = this.getCopiedKey(k)
column[k] = column[copiedKey]
})
if (column.columns && column.original_Columns) column.columns = column.original_Columns
}
getState = () => (this.props.onFoldChange ? this.props.folded : this.state.folded)
isFolded = col => {
const folded = this.getState()
return folded[col.id] === true
}
foldingHandler = col => {
if (!col || !col.id) return
const { onFoldChange } = this.props
const folded = this.getState()
const { id } = col
const newFold = Object.assign({}, folded)
newFold[id] = !newFold[id]
// Remove the Resized if have
this.removeResized(col)
if (onFoldChange) onFoldChange(newFold)
else {
this.setState(previous => ({ folded: newFold }))
}
}
foldableHeaderRender = cell => {
const { FoldButtonComponent, FoldIconComponent } = this.props
const { column } = cell
const collapsed = this.isFolded(column)
const icon = React.createElement(FoldIconComponent, { collapsed })
const onClick = () => this.foldingHandler(column)
return React.createElement(FoldButtonComponent, {
header: column.original_Header,
collapsed,
icon,
onClick,
})
}
applyFoldableForColumn = column => {
const collapsed = this.isFolded(column)
const { FoldedColumn } = this.props
// Handle Column Header
if (column.columns) {
if (collapsed) {
column.columns = [FoldedColumn]
column.width = FoldedColumn.width
column.style = FoldedColumn.style
} else this.restoreToOriginal(column)
}
// Handle Normal Column.
else if (collapsed) column = Object.assign(column, FoldedColumn)
else {
this.restoreToOriginal(column)
}
}
applyFoldableForColumns = columns =>
columns.map((col, index) => {
if (!col.foldable) return col
// If col don't have id then generate id based on index
if (!col.id) col.id = `col_${index}`
this.copyOriginals(col)
// Replace current header with internal header render.
col.Header = c => this.foldableHeaderRender(c)
// apply foldable
this.applyFoldableForColumn(col)
// return the new column out
return col
})
render() {
const {
columns: originalCols,
FoldButtonComponent,
FoldIconComponent,
FoldedColumn,
...rest
} = this.props
const columns = this.applyFoldableForColumns([...originalCols])
const extra = {
columns,
onResizedChange: this.onResizedChange,
resized: this.state.resized,
}
return <ReactTable {...rest} {...extra} ref={r => (this.wrappedInstance = r)} />
}
}
wrapper.displayName = 'RTFoldableTable'
wrapper.defaultProps = {
FoldIconComponent: defaultFoldIconComponent,
FoldButtonComponent: defaultFoldButtonComponent,
foldableOriginalKey: 'original_',
FoldedColumn: {
Cell: c => '',
width: 30,
sortable: false,
resizable: false,
filterable: false,
},
}
return wrapper
}
+1
View File
@@ -0,0 +1 @@
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="512px" id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M327.3,98.9l-2.1,1.8l-156.5,136c-5.3,4.6-8.6,11.5-8.6,19.2c0,7.7,3.4,14.6,8.6,19.2L324.9,411l2.6,2.3 c2.5,1.7,5.5,2.7,8.7,2.7c8.7,0,15.8-7.4,15.8-16.6h0V112.6h0c0-9.2-7.1-16.6-15.8-16.6C332.9,96,329.8,97.1,327.3,98.9z"/></svg>

After

Width:  |  Height:  |  Size: 583 B

+1
View File
@@ -0,0 +1 @@
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="512px" id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M184.7,413.1l2.1-1.8l156.5-136c5.3-4.6,8.6-11.5,8.6-19.2c0-7.7-3.4-14.6-8.6-19.2L187.1,101l-2.6-2.3 C182,97,179,96,175.8,96c-8.7,0-15.8,7.4-15.8,16.6h0v286.8h0c0,9.2,7.1,16.6,15.8,16.6C179.1,416,182.2,414.9,184.7,413.1z"/></svg>

After

Width:  |  Height:  |  Size: 585 B

+8 -4
View File
@@ -6,7 +6,9 @@ const defaultSelectInputComponent = props => {
return (
<input
type={props.selectType || 'checkbox'}
aria-label={`${props.checked ? 'Un-select':'Select'} row with id:${props.id}` }
checked={props.checked}
id={props.id}
onClick={e => {
const { shiftKey } = e
e.stopPropagation()
@@ -17,7 +19,7 @@ const defaultSelectInputComponent = props => {
)
}
export default Component => {
export default (Component, options) => {
const wrapper = class RTSelectTable extends React.Component {
constructor(props) {
super(props)
@@ -31,8 +33,8 @@ export default Component => {
checked,
onClick: toggleSelection,
selectType,
id: row[keyField],
row,
id: `select-${row[keyField]}`
}
return React.createElement(this.props.SelectInputComponent, inputProps)
}
@@ -46,6 +48,7 @@ export default Component => {
checked,
onClick: toggleAll,
selectType,
id: 'select-all'
}
return React.createElement(SelectAllInputComponent, inputProps)
@@ -85,7 +88,8 @@ export default Component => {
resizable: false,
style: { textAlign: 'center' },
}
const columns = [select, ...originalCols]
const columns = (options !== undefined && options.floatingLeft === true) ? [...originalCols, select] : [select, ...originalCols]
const extra = {
columns,
}
@@ -106,7 +110,7 @@ export default Component => {
toggleAll: () => {
console.log('No toggleAll handler provided.')
},
selectType: 'check',
selectType: 'checkbox',
SelectInputComponent: defaultSelectInputComponent,
SelectAllInputComponent: defaultSelectInputComponent,
}
+6 -2
View File
@@ -31,7 +31,7 @@ export default Component => {
cell.props.style.borderBottom = '1px solid rgba(128,128,128,0.2)'
return (
<div className={`rt-tr ${rest.className}`} style={rest.style}>
<div className={`rt-tr ${rest.className}`} role="row" style={rest.style}>
{cell}
</div>
)
@@ -49,12 +49,16 @@ export default Component => {
const extra = {
columns: columns.map(col => {
let column = col
if (rest.pivotBy && rest.pivotBy.includes(col.accessor)) {
if (rest.pivotBy && (rest.pivotBy.includes(col.accessor) || rest.pivotBy.includes(col.id))) {
column = {
id: col.id,
accessor: col.accessor,
width: `${treeTableIndent}px`,
show: false,
Header: '',
Expander: col.Expander,
PivotValue: col.PivotValue,
Pivot: col.Pivot,
}
}
return column
+33 -26
View File
@@ -34,7 +34,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
this.resizeColumnMoving = this.resizeColumnMoving.bind(this)
this.state = {
page: 0,
page: props.defaultPage,
pageSize: props.defaultPageSize,
sorted: props.defaultSorted,
expanded: props.defaultExpanded,
@@ -124,7 +124,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
PadRowComponent,
// Data model
resolvedData,
allVisibleColumns,
visibleColumns,
headerGroups,
hasHeaderGroups,
// Sorted Data
@@ -139,8 +139,8 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
const minRows = this.getMinRows()
const padRows = _.range(Math.max(minRows - pageRows.length, 0))
const hasColumnFooter = allVisibleColumns.some(d => d.Footer)
const hasFilters = filterable || allVisibleColumns.some(d => d.filterable)
const hasColumnFooter = visibleColumns.some(d => d.Footer)
const hasFilters = filterable || visibleColumns.some(d => d.filterable)
const recurseRowsViewIndex = (rows, path = [], index = -1) => [
rows.map((row, i) => {
@@ -167,7 +167,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
const canNext = page + 1 < pages
const rowMinWidth = _.sum(
allVisibleColumns.map(d => {
visibleColumns.map(d => {
const resizedColumn = resized.find(x => x.id === d.id) || {}
return _.getFirstDefined(resizedColumn.value, d.width, d.minWidth)
})
@@ -198,14 +198,16 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
const makeHeaderGroup = (column, i) => {
const resizedValue = col => (resized.find(x => x.id === col.id) || {}).value
const leafColumns = _.leaves(column, 'columns')
const flex = _.sum(
column.columns.map(col => (col.width || resizedValue(col) ? 0 : col.minWidth))
leafColumns.map(col => (col.width || resizedValue(col) ? 0 : col.minWidth))
)
const width = _.sum(
column.columns.map(col => _.getFirstDefined(resizedValue(col), col.width, col.minWidth))
leafColumns.map(col => _.getFirstDefined(resizedValue(col), col.width, col.minWidth))
)
const maxWidth = _.sum(
column.columns.map(col => _.getFirstDefined(resizedValue(col), col.width, col.maxWidth))
leafColumns.map(col => _.getFirstDefined(resizedValue(col), col.width, col.maxWidth))
)
const theadGroupThProps = _.splitProps(
@@ -256,15 +258,16 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
)
}
const makeHeaderGroups = () => {
const makeHeaderGroups = (row, i) => {
const theadGroupProps = _.splitProps(
getTheadGroupProps(finalState, undefined, undefined, this)
getTheadGroupProps(finalState, undefined, row, this)
)
const theadGroupTrProps = _.splitProps(
getTheadGroupTrProps(finalState, undefined, undefined, this)
getTheadGroupTrProps(finalState, undefined, row, this)
)
return (
<TheadComponent
key={`${i}-${row.id}`}
className={classnames('-headerGroups', theadGroupProps.className)}
style={{
...theadGroupProps.style,
@@ -277,7 +280,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
style={theadGroupTrProps.style}
{...theadGroupTrProps.rest}
>
{headerGroups.map(makeHeaderGroup)}
{row.map(makeHeaderGroup)}
</TrComponent>
</TheadComponent>
)
@@ -368,7 +371,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
style={theadTrProps.style}
{...theadTrProps.rest}
>
{allVisibleColumns.map(makeHeader)}
{visibleColumns.map(makeHeader)}
</TrComponent>
</TheadComponent>
)
@@ -456,7 +459,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
style={theadFilterTrProps.style}
{...theadFilterTrProps.rest}
>
{allVisibleColumns.map(makeFilter)}
{visibleColumns.map(makeFilter)}
</TrComponent>
</TheadComponent>
)
@@ -486,7 +489,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
style={trProps.style}
{...trProps.rest}
>
{allVisibleColumns.map((column, i2) => {
{visibleColumns.map((column, i2) => {
const resizedCol = resized.find(x => x.id === column.id) || {}
const show = typeof column.show === 'function' ? column.show() : column.show
const width = _.getFirstDefined(resizedCol.value, column.width, column.minWidth)
@@ -643,7 +646,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
key={`${i2}-${column.id}`}
className={classnames(
classes,
!show && 'hidden',
!cellInfo.expandable && !show && 'hidden',
cellInfo.expandable && 'rt-expandable',
(isBranch || isPreview) && 'rt-pivot'
)}
@@ -665,7 +668,11 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
{rowInfo.subRows &&
isExpanded &&
rowInfo.subRows.map((d, i) => makePageRow(d, i, rowInfo.nestingPath))}
{SubComponent && !rowInfo.subRows && isExpanded && SubComponent(rowInfo)}
{SubComponent && !rowInfo.subRows && isExpanded && SubComponent(rowInfo, () => {
const newExpanded = _.clone(expanded)
_.set(newExpanded, cellInfo.nestingPath, false)
})}
</TrGroupComponent>
)
}
@@ -708,7 +715,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
const trGroupProps = getTrGroupProps(finalState, undefined, undefined, this)
const trProps = _.splitProps(getTrProps(finalState, undefined, undefined, this))
return (
<TrGroupComponent key={i} {...trGroupProps}>
<TrGroupComponent key={`pad-${i}`} {...trGroupProps}>
<TrComponent
className={classnames(
'-padRow',
@@ -717,7 +724,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
)}
style={trProps.style || {}}
>
{allVisibleColumns.map(makePadColumn)}
{visibleColumns.map(makePadColumn)}
</TrComponent>
</TrGroupComponent>
)
@@ -771,7 +778,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
}
const makeColumnFooters = () => {
const tFootProps = getTfootProps(finalState, undefined, undefined, this)
const tFootProps = _.splitProps(getTfootProps(finalState, undefined, undefined, this))
const tFootTrProps = _.splitProps(getTfootTrProps(finalState, undefined, undefined, this))
return (
<TfootComponent
@@ -787,13 +794,13 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
style={tFootTrProps.style}
{...tFootTrProps.rest}
>
{allVisibleColumns.map(makeColumnFooter)}
{visibleColumns.map(makeColumnFooter)}
</TrComponent>
</TfootComponent>
)
}
const makePagination = () => {
const makePagination = (isTop) => {
const paginationProps = _.splitProps(
getPaginationProps(finalState, undefined, undefined, this)
)
@@ -807,13 +814,13 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
onPageSizeChange={this.onPageSizeChange}
className={paginationProps.className}
style={paginationProps.style}
isTop={isTop}
{...paginationProps.rest}
/>
)
}
const makeTable = () => {
const pagination = makePagination()
return (
<div
className={classnames('ReactTable', className, rootProps.className)}
@@ -824,14 +831,14 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
{...rootProps.rest}
>
{showPagination && showPaginationTop ? (
<div className="pagination-top">{pagination}</div>
<div className="pagination-top">{makePagination(true)}</div>
) : null}
<TableComponent
className={classnames(tableProps.className, currentlyResizing ? 'rt-resizing' : '')}
style={tableProps.style}
{...tableProps.rest}
>
{hasHeaderGroups ? makeHeaderGroups() : null}
{hasHeaderGroups ? headerGroups.map(makeHeaderGroups) : null}
{makeHeaders()}
{hasFilters ? makeFilters() : null}
<TbodyComponent
@@ -848,7 +855,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
{hasColumnFooter ? makeColumnFooters() : null}
</TableComponent>
{showPagination && showPaginationBottom ? (
<div className="pagination-bottom">{pagination}</div>
<div className="pagination-bottom">{makePagination(false)}</div>
) : null}
{!pageRows.length && (
<NoDataComponent {...noDataProps}>{_.normalizeComponent(noDataText)}</NoDataComponent>
+3
View File
@@ -73,6 +73,9 @@ input-select-style()
&:last-child
border-right: 0
.rt-th:focus
outline: none
.rt-resizable-header
overflow: visible
&:last-child
+3 -3
View File
@@ -1,7 +1,7 @@
export default Base =>
class extends Base {
componentWillMount () {
this.setStateWithData(this.getDataModel(this.getResolvedState()))
this.setStateWithData(this.getDataModel(this.getResolvedState(), true))
}
componentDidMount () {
@@ -44,7 +44,7 @@ export default Base =>
oldState.sorted !== newState.sorted ||
oldState.filtered !== newState.filtered
) {
this.setStateWithData(this.getDataModel(newState))
this.setStateWithData(this.getDataModel(newState, oldState.data !== newState.data))
}
}
@@ -103,7 +103,7 @@ export default Base =>
newResolvedState.pages = newResolvedState.manual
? newResolvedState.pages
: Math.ceil(newResolvedState.sortedData.length / newResolvedState.pageSize)
newResolvedState.page = Math.max(
newResolvedState.page = newResolvedState.manual ? newResolvedState.page : Math.max(
newResolvedState.page >= newResolvedState.pages
? newResolvedState.pages - 1
: newResolvedState.page,
+105 -82
View File
@@ -13,11 +13,12 @@ export default Base =>
return resolvedState
}
getDataModel (newState) {
getDataModel (newState, dataChanged) {
const {
columns,
pivotBy = [],
data,
resolveData,
pivotIDKey,
pivotValKey,
subRowsKey,
@@ -29,29 +30,18 @@ export default Base =>
SubComponent,
} = newState
// Determine Header Groups
let hasHeaderGroups = false
columns.forEach(column => {
if (column.columns) {
hasHeaderGroups = true
}
})
// Determine if there are Header Groups
const hasHeaderGroups = columns.some(column => column.columns)
let columnsWithExpander = [...columns]
let expanderColumn = columns.find(
col => col.expander || (col.columns && col.columns.some(col2 => col2.expander))
)
// The actual expander might be in the columns field of a group column
if (expanderColumn && !expanderColumn.expander) {
expanderColumn = expanderColumn.columns.find(col => col.expander)
}
// Find the expander column which could be deep in tree of columns
const allColumns = _.iterTree(columns, 'columns')
const expanderColumn = _.getFirstDefined(allColumns)
// If we have SubComponent's we need to make sure we have an expander column
if (SubComponent && !expanderColumn) {
expanderColumn = { expander: true }
columnsWithExpander = [expanderColumn, ...columnsWithExpander]
}
const hasSubComponentAndNoExpanderColumn = SubComponent && !expanderColumn
const columnsWithExpander = hasSubComponentAndNoExpanderColumn
? [{ expander: true }, ...columns]
: [...columns]
const makeDecoratedColumn = (column, parentColumn) => {
let dcol
@@ -63,6 +53,7 @@ export default Base =>
}
} else {
dcol = {
...this.props.column,
...this.props.column,
...column,
}
@@ -104,40 +95,31 @@ export default Base =>
const allDecoratedColumns = []
// Decorate the columns
const decorateAndAddToAll = (column, parentColumn) => {
const decorateAndAddToAll = (columns, parentColumn) => columns.map(column => {
const decoratedColumn = makeDecoratedColumn(column, parentColumn)
if (column.columns) {
decoratedColumn.columns = decorateAndAddToAll(column.columns, column)
}
allDecoratedColumns.push(decoratedColumn)
return decoratedColumn
}
const decoratedColumns = columnsWithExpander.map(column => {
if (column.columns) {
return {
...column,
columns: column.columns.map(d => decorateAndAddToAll(d, column)),
}
}
return decorateAndAddToAll(column)
})
// Build the visible columns, headers and flat column list
let visibleColumns = decoratedColumns.slice()
let allVisibleColumns = []
visibleColumns = visibleColumns.map(column => {
const decoratedColumns = decorateAndAddToAll(columnsWithExpander)
const mapVisibleColumns = columns => columns.map(column => {
if (column.columns) {
const visibleSubColumns = column.columns.filter(
d => (pivotBy.indexOf(d.id) > -1 ? false : _.getFirstDefined(d.show, true))
)
return {
...column,
columns: visibleSubColumns,
columns: mapVisibleColumns(visibleSubColumns),
}
}
return column
})
visibleColumns = visibleColumns.filter(
const filterVisibleColumns = columns => columns.filter(
column =>
column.columns
? column.columns.length
@@ -146,8 +128,12 @@ export default Base =>
: _.getFirstDefined(column.show, true)
)
// Build the full array of visible columns - this is an array that contains all columns that
// are not hidden via pivoting
const allVisibleColumns = filterVisibleColumns(mapVisibleColumns(decoratedColumns.slice()))
// Find any custom pivot location
const pivotIndex = visibleColumns.findIndex(col => col.pivot)
const pivotIndex = allVisibleColumns.findIndex(col => col.pivot)
// Handle Pivot Columns
if (pivotBy.length) {
@@ -180,46 +166,66 @@ export default Base =>
// Place the pivotColumns back into the visibleColumns
if (pivotIndex >= 0) {
pivotColumnGroup = {
...visibleColumns[pivotIndex],
...allVisibleColumns[pivotIndex],
...pivotColumnGroup,
}
visibleColumns.splice(pivotIndex, 1, pivotColumnGroup)
allVisibleColumns.splice(pivotIndex, 1, pivotColumnGroup)
} else {
visibleColumns.unshift(pivotColumnGroup)
allVisibleColumns.unshift(pivotColumnGroup)
}
}
// Build Header Groups
const headerGroups = []
let currentSpan = []
// Build Visible Columns and Header Groups
const allColumnHeaders = []
// A convenience function to add a header and reset the currentSpan
const addHeader = (columns, column) => {
headerGroups.push({
...this.props.column,
...column,
columns,
})
currentSpan = []
}
const addHeader = column => {
let level = 0
// Build flast list of allVisibleColumns and HeaderGroups
visibleColumns.forEach(column => {
// If this column has children, push them first and add this column to the next level
if (column.columns) {
allVisibleColumns = allVisibleColumns.concat(column.columns)
if (currentSpan.length > 0) {
addHeader(currentSpan)
}
addHeader(column.columns, column)
return
const childLevels = column.columns.map(addHeader)
level = Math.max(...childLevels) + 1
}
allVisibleColumns.push(column)
currentSpan.push(column)
})
if (hasHeaderGroups && currentSpan.length > 0) {
addHeader(currentSpan)
// Add spans above columns without parents (orphans) to fill the space above them
if (allColumnHeaders.length <= level) allColumnHeaders.push([])
if (level > 0) {
// The spans need to contain the shifted headers as children. This finds all of the
// columns in the lower level between the first child of this column and the last child
// of the preceding column (if there is one)
const lowerLevel = allColumnHeaders[level - 1]
const precedingColumn = _.last(allColumnHeaders[level])
const indexOfFirstChildInLowerLevel = lowerLevel.indexOf(column.columns[0])
const indexAfterLastChildInPrecedingColumn = precedingColumn
? lowerLevel.indexOf(_.last(precedingColumn.columns)) + 1
: 0
// If there are ophans, add a span above them
const orphans = lowerLevel.slice(
indexAfterLastChildInPrecedingColumn,
indexOfFirstChildInLowerLevel
)
if (orphans.length) {
allColumnHeaders[level].push({
...this.props.column,
columns: orphans,
})
}
}
allColumnHeaders[level].push(column)
return level
}
allVisibleColumns.forEach(addHeader)
// visibleColumns is an array containing column definitions for the bottom row of TH elements
const visibleColumns = allColumnHeaders.shift()
const headerGroups = allColumnHeaders.reverse()
// Access the data
const accessRow = (d, i, level = 0) => {
const row = {
@@ -237,10 +243,19 @@ export default Base =>
}
return row
}
let resolvedData = data.map((d, i) => accessRow(d, i))
// // If the data hasn't changed, just use the cached data
let resolvedData = this.resolvedData
// If the data has changed, run the data resolver and cache the result
if (!this.resolvedData || dataChanged) {
resolvedData = resolveData(data)
this.resolvedData = resolvedData
}
// Use the resolved data
resolvedData = resolvedData.map((d, i) => accessRow(d, i))
// TODO: Make it possible to fabricate nested rows without pivoting
const aggregatingColumns = allVisibleColumns.filter(d => !d.expander && d.aggregate)
const aggregatingColumns = visibleColumns.filter(d => !d.expander && d.aggregate)
// If pivoting, recursively group the data
const aggregate = rows => {
@@ -284,7 +299,7 @@ export default Base =>
return {
...newState,
resolvedData,
allVisibleColumns,
visibleColumns,
headerGroups,
allDecoratedColumns,
hasHeaderGroups,
@@ -298,7 +313,7 @@ export default Base =>
filtered,
defaultFilterMethod,
resolvedData,
allVisibleColumns,
visibleColumns,
allDecoratedColumns,
} = resolvedState
@@ -313,7 +328,7 @@ export default Base =>
sortedData: manual
? resolvedData
: this.sortData(
this.filterData(resolvedData, filtered, defaultFilterMethod, allVisibleColumns),
this.filterData(resolvedData, filtered, defaultFilterMethod, allDecoratedColumns),
sorted,
sortMethodsByColumnID
),
@@ -321,7 +336,15 @@ export default Base =>
}
fireFetchData () {
this.props.onFetchData(this.getResolvedState(), this)
// determine the current state, preferring certain state values over props
const currentState = {
...this.getResolvedState(),
page: this.getStateOrProp('page'),
pageSize: this.getStateOrProp('pageSize'),
filter: this.getStateOrProp('filter'),
};
this.props.onFetchData(currentState, this)
}
getPropOrState (key) {
@@ -332,12 +355,12 @@ export default Base =>
return _.getFirstDefined(this.state[key], this.props[key])
}
filterData (data, filtered, defaultFilterMethod, allVisibleColumns) {
filterData (data, filtered, defaultFilterMethod, visibleColumns) {
let filteredData = data
if (filtered.length) {
filteredData = filtered.reduce((filteredSoFar, nextFilter) => {
const column = allVisibleColumns.find(x => x.id === nextFilter.id)
const column = visibleColumns.find(x => x.id === nextFilter.id)
// Don't filter hidden columns or columns that have had their filters disabled
if (!column || column.filterable === false) {
@@ -366,7 +389,7 @@ export default Base =>
row[this.props.subRowsKey],
filtered,
defaultFilterMethod,
allVisibleColumns
visibleColumns
),
}
})
@@ -606,8 +629,10 @@ export default Base =>
resizeColumnMoving (event) {
event.stopPropagation()
const { onResizedChange } = this.props
const { resized, currentlyResizing } = this.getResolvedState()
const { onResizedChange, column } = this.props
const { resized, currentlyResizing, columns } = this.getResolvedState()
const currentColumn = columns.find(c => c.accessor === currentlyResizing.id)
const minResizeWidth = currentColumn ? currentColumn.minResizeWidth : column.minResizeWidth
// Delete old value
const newResized = resized.filter(x => x.id !== currentlyResizing.id)
@@ -620,11 +645,9 @@ export default Base =>
pageX = event.pageX
}
// Set the min size to 10 to account for margin and border or else the
// group headers don't line up correctly
const newWidth = Math.max(
currentlyResizing.parentWidth + pageX - currentlyResizing.startX,
11
minResizeWidth
)
newResized.push({
+85 -43
View File
@@ -1,7 +1,5 @@
import React, { Component } from 'react'
import classnames from 'classnames'
//
// import _ from './utils'
const defaultButton = props => (
<button type="button" {...props} className="-btn">
@@ -10,8 +8,51 @@ const defaultButton = props => (
)
export default class ReactTablePagination extends Component {
static defaultProps = {
PreviousComponent: defaultButton,
NextComponent: defaultButton,
renderPageJump: ({
onChange, value, onBlur, onKeyPress, inputType, pageJumpText,
}) => (
<div className="-pageJump">
<input
aria-label={pageJumpText}
type={inputType}
onChange={onChange}
value={value}
onBlur={onBlur}
onKeyPress={onKeyPress}
/>
</div>
),
renderCurrentPage: page => <span className="-currentPage">{page + 1}</span>,
renderTotalPagesCount: pages => <span className="-totalPages">{pages || 1}</span>,
renderPageSizeOptions: ({
pageSize,
pageSizeOptions,
rowsSelectorText,
onPageSizeChange,
rowsText,
}) => (
<span className="select-wrap -pageSizeOptions">
<select
aria-label={rowsSelectorText}
onChange={e => onPageSizeChange(Number(e.target.value))}
value={pageSize}
>
{pageSizeOptions.map((option, i) => (
// eslint-disable-next-line react/no-array-index-key
<option key={i} value={option}>
{`${option} ${rowsText}`}
</option>
))}
</select>
</span>
),
}
constructor (props) {
super()
super(props)
this.getSafePage = this.getSafePage.bind(this)
this.changePage = this.changePage.bind(this)
@@ -23,7 +64,9 @@ export default class ReactTablePagination extends Component {
}
componentWillReceiveProps (nextProps) {
this.setState({ page: nextProps.page })
if (this.props.page !== nextProps.page) {
this.setState({ page: nextProps.page })
}
}
getSafePage (page) {
@@ -49,6 +92,28 @@ export default class ReactTablePagination extends Component {
this.changePage(page === '' ? this.props.page : page)
}
getPageJumpProperties () {
return {
onKeyPress: e => {
if (e.which === 13 || e.keyCode === 13) {
this.applyPage()
}
},
onBlur: this.applyPage,
value: this.state.page === '' ? '' : this.state.page + 1,
onChange: e => {
const val = e.target.value
const page = val - 1
if (val === '') {
return this.setState({ page: val })
}
this.setState({ page: this.getSafePage(page) })
},
inputType: this.state.page === '' ? 'text' : 'number',
pageJumpText: this.props.pageJumpText,
}
}
render () {
const {
// Computed
@@ -63,8 +128,12 @@ export default class ReactTablePagination extends Component {
canNext,
onPageSizeChange,
className,
PreviousComponent = defaultButton,
NextComponent = defaultButton,
PreviousComponent,
NextComponent,
renderPageJump,
renderCurrentPage,
renderTotalPagesCount,
renderPageSizeOptions,
} = this.props
return (
@@ -83,44 +152,17 @@ export default class ReactTablePagination extends Component {
<div className="-center">
<span className="-pageInfo">
{this.props.pageText}{' '}
{showPageJump ? (
<div className="-pageJump">
<input
type={this.state.page === '' ? 'text' : 'number'}
onChange={e => {
const val = e.target.value
const page = val - 1
if (val === '') {
return this.setState({ page: val })
}
this.setState({ page: this.getSafePage(page) })
}}
value={this.state.page === '' ? '' : this.state.page + 1}
onBlur={this.applyPage}
onKeyPress={e => {
if (e.which === 13 || e.keyCode === 13) {
this.applyPage()
}
}}
/>
</div>
) : (
<span className="-currentPage">{page + 1}</span>
)}{' '}
{this.props.ofText} <span className="-totalPages">{pages || 1}</span>
{showPageJump ? renderPageJump(this.getPageJumpProperties()) : renderCurrentPage(page)}{' '}
{this.props.ofText} {renderTotalPagesCount(pages)}
</span>
{showPageSizeOptions && (
<span className="select-wrap -pageSizeOptions">
<select onChange={e => onPageSizeChange(Number(e.target.value))} value={pageSize}>
{pageSizeOptions.map((option, i) => (
// eslint-disable-next-line react/no-array-index-key
<option key={i} value={option}>
{option} {this.props.rowsText}
</option>
))}
</select>
</span>
)}
{showPageSizeOptions &&
renderPageSizeOptions({
pageSize,
rowsSelectorText: this.props.rowsSelectorText,
pageSizeOptions,
onPageSizeChange,
rowsText: this.props.rowsText,
})}
</div>
<div className="-next">
<NextComponent
+5 -2
View File
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types'
export default {
// General
data: PropTypes.array,
data: PropTypes.any,
loading: PropTypes.bool,
showPagination: PropTypes.bool,
showPaginationTop: PropTypes.bool,
@@ -97,6 +97,7 @@ export default {
filterable: PropTypes.bool, // use table default
show: PropTypes.bool,
minWidth: PropTypes.number,
minResizeWidth: PropTypes.number,
// Cells only
className: PropTypes.string,
@@ -114,7 +115,7 @@ export default {
// Footers only
footerClassName: PropTypes.string,
footerStyle: PropTypes.object,
getFooterProps: PropTypes.object,
getFooterProps: PropTypes.func,
filterMethod: PropTypes.func,
filterAll: PropTypes.bool,
sortMethod: PropTypes.func,
@@ -139,6 +140,8 @@ export default {
pageText: PropTypes.node,
ofText: PropTypes.node,
rowsText: PropTypes.node,
pageJumpText: PropTypes.node,
rowsSelectorText: PropTypes.node,
// Components
TableComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
+21 -5
View File
@@ -10,6 +10,8 @@ export default {
range,
remove,
clone,
leaves,
iterTree,
getFirstDefined,
sum,
makeTemplateComponent,
@@ -108,6 +110,24 @@ function clone (a) {
}
}
function leaves (root, childProperty) {
if (Object.prototype.hasOwnProperty.call(root, childProperty)) {
const children = root[childProperty].map(child => leaves(child, childProperty))
return [].concat(...children)
}
return [root]
}
function iterTree (root, childProperty) {
if (Object.prototype.hasOwnProperty.call(root, childProperty)) {
const children = root[childProperty].map(child => leaves(child, childProperty))
return [].concat(root, ...children)
}
return [root]
}
function getFirstDefined (...args) {
for (let i = 0; i < args.length; i += 1) {
if (typeof args[i] !== 'undefined') {
@@ -205,11 +225,7 @@ function isSortingDesc (d) {
function normalizeComponent (Comp, params = {}, fallback = Comp) {
return typeof Comp === 'function' ? (
Object.getPrototypeOf(Comp).isReactComponent ? (
<Comp {...params} />
) : (
Comp(params)
)
<Comp {...params} />
) : (
fallback
)
+164 -194
View File
@@ -144,13 +144,7 @@ ansi-styles@^2.1.0, ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
ansi-styles@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88"
dependencies:
color-convert "^1.9.0"
ansi-styles@^3.2.1:
ansi-styles@^3.2.0, ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
dependencies:
@@ -389,13 +383,13 @@ babel-generator@^6.22.0:
lodash "^4.2.0"
source-map "^0.5.0"
babel-helper-builder-binary-assignment-operator-visitor@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.22.0.tgz#29df56be144d81bdeac08262bfa41d2c5e91cdcd"
babel-helper-builder-binary-assignment-operator-visitor@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664"
dependencies:
babel-helper-explode-assignable-expression "^6.22.0"
babel-helper-explode-assignable-expression "^6.24.1"
babel-runtime "^6.22.0"
babel-types "^6.22.0"
babel-types "^6.24.1"
babel-helper-builder-react-jsx@^6.24.1:
version "6.26.0"
@@ -423,23 +417,13 @@ babel-helper-define-map@^6.24.1:
babel-types "^6.26.0"
lodash "^4.17.4"
babel-helper-explode-assignable-expression@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.22.0.tgz#c97bf76eed3e0bae4048121f2b9dae1a4e7d0478"
babel-helper-explode-assignable-expression@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa"
dependencies:
babel-runtime "^6.22.0"
babel-traverse "^6.22.0"
babel-types "^6.22.0"
babel-helper-function-name@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.22.0.tgz#51f1bdc4bb89b15f57a9b249f33d742816dcbefc"
dependencies:
babel-helper-get-function-arity "^6.22.0"
babel-runtime "^6.22.0"
babel-template "^6.22.0"
babel-traverse "^6.22.0"
babel-types "^6.22.0"
babel-traverse "^6.24.1"
babel-types "^6.24.1"
babel-helper-function-name@^6.24.1:
version "6.24.1"
@@ -451,13 +435,6 @@ babel-helper-function-name@^6.24.1:
babel-traverse "^6.24.1"
babel-types "^6.24.1"
babel-helper-get-function-arity@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.22.0.tgz#0beb464ad69dc7347410ac6ade9f03a50634f5ce"
dependencies:
babel-runtime "^6.22.0"
babel-types "^6.22.0"
babel-helper-get-function-arity@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d"
@@ -487,15 +464,15 @@ babel-helper-regex@^6.24.1:
babel-types "^6.26.0"
lodash "^4.17.4"
babel-helper-remap-async-to-generator@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.22.0.tgz#2186ae73278ed03b8b15ced089609da981053383"
babel-helper-remap-async-to-generator@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b"
dependencies:
babel-helper-function-name "^6.22.0"
babel-helper-function-name "^6.24.1"
babel-runtime "^6.22.0"
babel-template "^6.22.0"
babel-traverse "^6.22.0"
babel-types "^6.22.0"
babel-template "^6.24.1"
babel-traverse "^6.24.1"
babel-types "^6.24.1"
babel-helper-replace-supers@^6.24.1:
version "6.24.1"
@@ -515,13 +492,7 @@ babel-helpers@^6.22.0:
babel-runtime "^6.22.0"
babel-template "^6.22.0"
babel-messages@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.22.0.tgz#36066a214f1217e4ed4164867669ecb39e3ea575"
dependencies:
babel-runtime "^6.22.0"
babel-messages@^6.23.0:
babel-messages@^6.22.0, babel-messages@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e"
dependencies:
@@ -568,10 +539,10 @@ babel-plugin-syntax-trailing-function-commas@^6.22.0:
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3"
babel-plugin-transform-async-to-generator@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.22.0.tgz#194b6938ec195ad36efc4c33a971acf00d8cd35e"
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761"
dependencies:
babel-helper-remap-async-to-generator "^6.22.0"
babel-helper-remap-async-to-generator "^6.24.1"
babel-plugin-syntax-async-functions "^6.8.0"
babel-runtime "^6.22.0"
@@ -660,15 +631,7 @@ babel-plugin-transform-es2015-literals@^6.22.0:
dependencies:
babel-runtime "^6.22.0"
babel-plugin-transform-es2015-modules-amd@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.22.0.tgz#bf69cd34889a41c33d90dfb740e0091ccff52f21"
dependencies:
babel-plugin-transform-es2015-modules-commonjs "^6.22.0"
babel-runtime "^6.22.0"
babel-template "^6.22.0"
babel-plugin-transform-es2015-modules-amd@^6.24.1:
babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154"
dependencies:
@@ -676,18 +639,9 @@ babel-plugin-transform-es2015-modules-amd@^6.24.1:
babel-runtime "^6.22.0"
babel-template "^6.24.1"
babel-plugin-transform-es2015-modules-commonjs@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.22.0.tgz#6ca04e22b8e214fb50169730657e7a07dc941145"
dependencies:
babel-plugin-transform-strict-mode "^6.22.0"
babel-runtime "^6.22.0"
babel-template "^6.22.0"
babel-types "^6.22.0"
babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a"
version "6.26.2"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3"
dependencies:
babel-plugin-transform-strict-mode "^6.24.1"
babel-runtime "^6.26.0"
@@ -770,10 +724,10 @@ babel-plugin-transform-es2015-unicode-regex@^6.22.0:
regexpu-core "^2.0.0"
babel-plugin-transform-exponentiation-operator@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.22.0.tgz#d57c8335281918e54ef053118ce6eb108468084d"
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e"
dependencies:
babel-helper-builder-binary-assignment-operator-visitor "^6.22.0"
babel-helper-builder-binary-assignment-operator-visitor "^6.24.1"
babel-plugin-syntax-exponentiation-operator "^6.8.0"
babel-runtime "^6.22.0"
@@ -825,13 +779,6 @@ babel-plugin-transform-regenerator@^6.22.0:
dependencies:
regenerator-transform "^0.10.0"
babel-plugin-transform-strict-mode@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.22.0.tgz#e008df01340fdc87e959da65991b7e05970c8c7c"
dependencies:
babel-runtime "^6.22.0"
babel-types "^6.22.0"
babel-plugin-transform-strict-mode@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758"
@@ -848,8 +795,8 @@ babel-polyfill@^6.9.0:
regenerator-runtime "^0.10.0"
babel-preset-env@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.6.1.tgz#a18b564cc9b9afdf4aae57ae3c1b0d99188e6f48"
version "1.7.0"
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a"
dependencies:
babel-plugin-check-es2015-constants "^6.22.0"
babel-plugin-syntax-trailing-function-commas "^6.22.0"
@@ -878,7 +825,7 @@ babel-preset-env@^1.6.1:
babel-plugin-transform-es2015-unicode-regex "^6.22.0"
babel-plugin-transform-exponentiation-operator "^6.22.0"
babel-plugin-transform-regenerator "^6.22.0"
browserslist "^2.1.2"
browserslist "^3.2.6"
invariant "^2.2.2"
semver "^5.3.0"
@@ -911,31 +858,21 @@ babel-register@^6.14.0, babel-register@^6.22.0:
mkdirp "^0.5.1"
source-map-support "^0.4.2"
babel-runtime@^6.18.0, babel-runtime@^6.6.1, babel-runtime@^6.9.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.22.0.tgz#1cf8b4ac67c77a4ddb0db2ae1f74de52ac4ca611"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-runtime@^6.22.0, babel-runtime@^6.26.0:
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"
babel-template@^6.22.0:
babel-runtime@^6.6.1, babel-runtime@^6.9.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.22.0.tgz#403d110905a4626b317a2a1fcb8f3b73204b2edb"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.22.0.tgz#1cf8b4ac67c77a4ddb0db2ae1f74de52ac4ca611"
dependencies:
babel-runtime "^6.22.0"
babel-traverse "^6.22.0"
babel-types "^6.22.0"
babylon "^6.11.0"
lodash "^4.2.0"
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-template@^6.24.1, babel-template@^6.26.0:
babel-template@^6.22.0, babel-template@^6.24.1, babel-template@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
dependencies:
@@ -945,7 +882,7 @@ babel-template@^6.24.1, babel-template@^6.26.0:
babylon "^6.18.0"
lodash "^4.17.4"
babel-traverse@^6.0.20, babel-traverse@^6.22.0, babel-traverse@^6.22.1:
babel-traverse@^6.0.20, babel-traverse@^6.22.1:
version "6.22.1"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.22.1.tgz#3b95cd6b7427d6f1f757704908f2fc9748a5f59f"
dependencies:
@@ -973,7 +910,7 @@ babel-traverse@^6.24.1, babel-traverse@^6.26.0:
invariant "^2.2.2"
lodash "^4.17.4"
babel-types@^6.0.19, babel-types@^6.19.0, babel-types@^6.22.0:
babel-types@^6.0.19:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.22.0.tgz#2a447e8d0ea25d2512409e4175479fd78cc8b1db"
dependencies:
@@ -982,7 +919,7 @@ babel-types@^6.0.19, babel-types@^6.19.0, babel-types@^6.22.0:
lodash "^4.2.0"
to-fast-properties "^1.0.1"
babel-types@^6.24.1, babel-types@^6.26.0:
babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.24.1, babel-types@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
dependencies:
@@ -995,11 +932,11 @@ babylon@7.0.0-beta.44:
version "7.0.0-beta.44"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.44.tgz#89159e15e6e30c5096e22d738d8c0af8a0e8ca1d"
babylon@^6.0.18, babylon@^6.11.0, babylon@^6.15.0:
babylon@^6.0.18:
version "6.15.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e"
babylon@^6.18.0:
babylon@^6.11.0, babylon@^6.15.0, babylon@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
@@ -1070,12 +1007,12 @@ browserslist@^1.7.6:
caniuse-db "^1.0.30000639"
electron-to-chromium "^1.2.7"
browserslist@^2.1.2:
version "2.11.3"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-2.11.3.tgz#fe36167aed1bbcde4827ebfe71347a2cc70b99b2"
browserslist@^3.2.6:
version "3.2.7"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.7.tgz#aa488634d320b55e88bab0256184dbbcca1e6de9"
dependencies:
caniuse-lite "^1.0.30000792"
electron-to-chromium "^1.3.30"
caniuse-lite "^1.0.30000835"
electron-to-chromium "^1.3.45"
buffer-from@^1.0.0:
version "1.0.0"
@@ -1118,9 +1055,9 @@ caniuse-db@^1.0.30000634, caniuse-db@^1.0.30000639:
version "1.0.30000746"
resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000746.tgz#501098c66f5fbbf634c02f25508b05e8809910f4"
caniuse-lite@^1.0.30000792:
version "1.0.30000803"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000803.tgz#9939c37149d38d5f4540430490d240c03106a0f5"
caniuse-lite@^1.0.30000835:
version "1.0.30000843"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000843.tgz#4fdec258dc641c385744cdd49d23c5459c3d4411"
caseless@~0.11.0:
version "0.11.0"
@@ -1150,7 +1087,7 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"
chalk@^2.0.0, chalk@^2.1.0:
chalk@^2.0.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52"
dependencies:
@@ -1158,6 +1095,14 @@ chalk@^2.0.0, chalk@^2.1.0:
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chalk@^2.1.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
@@ -1292,20 +1237,19 @@ core-js@^1.0.0:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
core-js@^2.4.0:
version "2.5.5"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.5.tgz#b14dde936c640c0579a6b50cabcc132dd6127e3b"
version "2.5.6"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.6.tgz#0fe6d45bf3cac3ac364a9d72de7576f4eb221b9d"
core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
create-react-class@^15.6.0:
version "15.6.2"
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.2.tgz#cf1ed15f12aad7f14ef5f2dfe05e6c42f91ef02a"
cross-env@^5.1.4:
version "5.1.4"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.4.tgz#f61c14291f7cc653bb86457002ea80a04699d022"
dependencies:
fbjs "^0.8.9"
loose-envify "^1.3.1"
object-assign "^4.1.1"
cross-spawn "^5.1.0"
is-windows "^1.0.0"
cross-spawn@^5.1.0, cross-spawn@~5.1.0:
version "5.1.0"
@@ -1315,6 +1259,16 @@ cross-spawn@^5.1.0, cross-spawn@~5.1.0:
shebang-command "^1.2.0"
which "^1.2.9"
cross-spawn@^6.0.4:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
semver "^5.5.0"
shebang-command "^1.2.0"
which "^1.2.9"
cryptiles@2.x.x:
version "2.0.5"
resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
@@ -1351,7 +1305,7 @@ debug-log@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/debug-log/-/debug-log-1.0.1.tgz#2307632d4c04382b8df8a32f70b895046d52745f"
debug@*, debug@^2.2.0:
debug@*:
version "2.6.8"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
dependencies:
@@ -1363,7 +1317,7 @@ debug@2.2.0:
dependencies:
ms "0.7.1"
debug@^2.1.1, debug@^2.6.8, debug@^2.6.9:
debug@^2.1.1, debug@^2.2.0, debug@^2.6.8, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
@@ -1466,9 +1420,9 @@ electron-to-chromium@^1.2.7:
version "1.3.26"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.26.tgz#996427294861a74d9c7c82b9260ea301e8c02d66"
electron-to-chromium@^1.3.30:
version "1.3.32"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.32.tgz#11d0684c0840e003c4be8928f8ac5f35dbc2b4e6"
electron-to-chromium@^1.3.45:
version "1.3.47"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.47.tgz#764e887ca9104d01a0ac8eabee7dfc0e2ce14104"
emoji-regex@^6.1.0:
version "6.5.1"
@@ -1486,16 +1440,7 @@ error-ex@^1.2.0, error-ex@^1.3.1:
dependencies:
is-arrayish "^0.2.1"
es-abstract@^1.4.3:
version "1.7.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.7.0.tgz#dfade774e01bfcd97f96180298c449c8623fb94c"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.0"
is-callable "^1.1.3"
is-regex "^1.0.3"
es-abstract@^1.7.0:
es-abstract@^1.4.3, es-abstract@^1.7.0:
version "1.11.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.11.0.tgz#cce87d518f0496893b1a30cd8461835535480681"
dependencies:
@@ -1650,7 +1595,22 @@ eslint-plugin-class-property@^1.0.6:
dependencies:
eslint "^3.19.0"
eslint-plugin-import@^2.7.0, eslint-plugin-import@^2.9.0:
eslint-plugin-import@^2.7.0:
version "2.12.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.12.0.tgz#dad31781292d6664b25317fd049d2e2b2f02205d"
dependencies:
contains-path "^0.1.0"
debug "^2.6.8"
doctrine "1.5.0"
eslint-import-resolver-node "^0.3.1"
eslint-module-utils "^2.2.0"
has "^1.0.1"
lodash "^4.17.4"
minimatch "^3.0.3"
read-pkg-up "^2.0.0"
resolve "^1.6.0"
eslint-plugin-import@^2.9.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.11.0.tgz#15aeea37a67499d848e8e981806d4627b5503816"
dependencies:
@@ -1706,7 +1666,16 @@ eslint-plugin-promise@~3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.5.0.tgz#78fbb6ffe047201627569e85a6c5373af2a68fca"
eslint-plugin-react@^7.4.0, eslint-plugin-react@^7.7.0:
eslint-plugin-react@^7.4.0:
version "7.8.2"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.8.2.tgz#e95c9c47fece55d2303d1a67c9d01b930b88a51d"
dependencies:
doctrine "^2.0.2"
has "^1.0.1"
jsx-ast-utils "^2.0.1"
prop-types "^15.6.0"
eslint-plugin-react@^7.7.0:
version "7.7.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.7.0.tgz#f606c719dbd8a1a2b3d25c16299813878cca0160"
dependencies:
@@ -1879,7 +1848,7 @@ event-emitter@~0.3.5:
event-stream@~3.3.0:
version "3.3.4"
resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571"
resolved "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571"
dependencies:
duplexer "~0.1.1"
from "~0"
@@ -2063,8 +2032,8 @@ form-data@~2.1.1:
mime-types "^2.1.12"
from@~0:
version "0.1.3"
resolved "https://registry.yarnpkg.com/from/-/from-0.1.3.tgz#ef63ac2062ac32acf7862e0d40b44b896f22f3bc"
version "0.1.7"
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
fs-readdir-recursive@^0.1.0:
version "0.1.2"
@@ -2404,13 +2373,7 @@ interpret@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"
invariant@^2.2.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"
dependencies:
loose-envify "^1.0.0"
invariant@^2.2.2:
invariant@^2.2.0, invariant@^2.2.2:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
dependencies:
@@ -2550,7 +2513,7 @@ is-property@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84"
is-regex@^1.0.3, is-regex@^1.0.4:
is-regex@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
dependencies:
@@ -2576,6 +2539,10 @@ is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
is-windows@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -2633,8 +2600,8 @@ jsesc@~0.5.0:
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d"
json-parse-better-errors@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz#50183cd1b2d25275de069e9e71b467ac9eab973a"
version "1.0.2"
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9"
json-schema-traverse@^0.3.0:
version "0.3.1"
@@ -2769,13 +2736,13 @@ lodash.pickby@^4.0.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff"
lodash@^4.0.0, lodash@^4.17.4, lodash@^4.3.0:
lodash@^4.0.0, lodash@^4.3.0:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
lodash@^4.2.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
lodash@^4.17.4, lodash@^4.2.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
log-symbols@^1.0.2:
version "1.0.2"
@@ -2797,8 +2764,8 @@ loud-rejection@^1.0.0:
signal-exit "^3.0.0"
lru-cache@^4.0.1:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.2.tgz#45234b2e6e2f2b33da125624c4664929a0224c3f"
version "4.1.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.3.tgz#a1175cf3496dfc8436c156c334b4955992bce69c"
dependencies:
pseudomap "^1.0.2"
yallist "^2.1.2"
@@ -2933,6 +2900,10 @@ next-tick@1:
version "1.0.0"
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
nice-try@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.4.tgz#d93962f6c52f2c1558c0fbda6d512819f1efe1c4"
node-fetch@^1.0.1:
version "1.7.3"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
@@ -2992,12 +2963,12 @@ normalize-range@^0.1.2:
resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942"
npm-run-all@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.2.tgz#90d62d078792d20669139e718621186656cea056"
version "4.1.3"
resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.3.tgz#49f15b55a66bb4101664ce270cb18e7103f8f185"
dependencies:
ansi-styles "^3.2.0"
chalk "^2.1.0"
cross-spawn "^5.1.0"
cross-spawn "^6.0.4"
memorystream "^0.3.1"
minimatch "^3.0.4"
ps-tree "^1.1.0"
@@ -3175,6 +3146,10 @@ path-is-inside@^1.0.1, path-is-inside@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
@@ -3307,8 +3282,8 @@ preserve@^0.2.0:
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
private@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.6.tgz#55c6a976d0f9bafb9924851350fe47b9b5fbb7c1"
version "0.1.8"
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
process-nextick-args@~2.0.0:
version "2.0.0"
@@ -3328,14 +3303,6 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"
prop-types@^15.5.10, prop-types@^15.6.0:
version "15.6.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
prop-types@^15.5.8:
version "15.5.10"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
@@ -3343,6 +3310,14 @@ prop-types@^15.5.8:
fbjs "^0.8.9"
loose-envify "^1.3.1"
prop-types@^15.6.0:
version "15.6.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.3.1"
object-assign "^4.1.1"
ps-tree@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.0.tgz#b421b24140d6203f1ed3c76996b4427b08e8c014"
@@ -3394,14 +3369,14 @@ react-base16-styling@^0.5.1:
lodash.flow "^3.3.0"
pure-color "^1.2.0"
react-dom@^15.4.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.2.tgz#41cfadf693b757faf2708443a1d1fd5a02bef730"
react-dom@^16.3.2:
version "16.4.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.4.1.tgz#7f8b0223b3a5fbe205116c56deb85de32685dad6"
dependencies:
fbjs "^0.8.9"
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.0"
prop-types "^15.5.10"
object-assign "^4.1.1"
prop-types "^15.6.0"
react-json-tree@^0.10.9:
version "0.10.9"
@@ -3411,15 +3386,14 @@ react-json-tree@^0.10.9:
prop-types "^15.5.8"
react-base16-styling "^0.5.1"
react@^15.4.2:
version "15.6.2"
resolved "https://registry.yarnpkg.com/react/-/react-15.6.2.tgz#dba0434ab439cfe82f108f0f511663908179aa72"
react@^16.3.2:
version "16.3.2"
resolved "https://registry.yarnpkg.com/react/-/react-16.3.2.tgz#fdc8420398533a1e58872f59091b272ce2f91ea9"
dependencies:
create-react-class "^15.6.0"
fbjs "^0.8.9"
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.0"
prop-types "^15.5.10"
object-assign "^4.1.1"
prop-types "^15.6.0"
read-file-stdin@^0.2.0:
version "0.2.1"
@@ -3508,8 +3482,8 @@ redent@^1.0.0:
strip-indent "^1.0.1"
regenerate@^1.2.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260"
version "1.4.0"
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
regenerator-runtime@^0.10.0:
version "0.10.5"
@@ -3675,8 +3649,8 @@ rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1:
glob "^7.0.5"
rollup-plugin-babel@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-3.0.3.tgz#63adedc863130327512a4a9006efc2241c5b7c15"
version "3.0.4"
resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-3.0.4.tgz#41b3e762fe64450dd61da3105a2cf7ad76be4edc"
dependencies:
rollup-pluginutils "^1.5.0"
@@ -3782,7 +3756,7 @@ semver-truncate@^1.0.0:
dependencies:
semver "^5.3.0"
"semver@2 || 3 || 4 || 5", semver@^5.3.0:
"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
@@ -4101,11 +4075,7 @@ tmp@^0.0.33:
dependencies:
os-tmpdir "~1.0.2"
to-fast-properties@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320"
to-fast-properties@^1.0.3:
to-fast-properties@^1.0.1, to-fast-properties@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"