mirror of
https://github.com/gosticks/react-table.git
synced 2026-10-06 15:57:04 +00:00
Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44db30fe73 | ||
|
|
b76f9c956d | ||
|
|
2e3743b75f | ||
|
|
fdb3e77b00 | ||
|
|
d9248cef2b | ||
|
|
f4704b146c | ||
|
|
004186af24 | ||
|
|
0d0e239baa | ||
|
|
f61b19cb8a | ||
|
|
e1a46fb77e | ||
|
|
a9db5b1ac6 | ||
|
|
846fc0d84d | ||
|
|
87610c83fa | ||
|
|
a58f5c4de2 | ||
|
|
1995bba652 | ||
|
|
680747d1d0 | ||
|
|
e70b29066b | ||
|
|
9d82cee707 | ||
|
|
db1edf119d | ||
|
|
c5fa476b6d | ||
|
|
550a1f7107 | ||
|
|
42e1a12ea9 | ||
|
|
15945d28a1 | ||
|
|
eaa7215674 | ||
|
|
d2835b9e14 | ||
|
|
5691fa2e7a | ||
|
|
f4aba6a008 | ||
|
|
7bce5a8958 | ||
|
|
875d3d93d6 | ||
|
|
a0ede1593b | ||
|
|
0d43b6d601 | ||
|
|
9dbd485cad |
@@ -0,0 +1,74 @@
|
|||||||
|
module.exports = {
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 8,
|
||||||
|
ecmaFeatures: {
|
||||||
|
experimentalObjectRestSpread: true,
|
||||||
|
jsx: true,
|
||||||
|
node: false
|
||||||
|
},
|
||||||
|
sourceType: 'module'
|
||||||
|
},
|
||||||
|
|
||||||
|
extends: ['standard'],
|
||||||
|
|
||||||
|
plugins: ['react'],
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
// Nozzle
|
||||||
|
'jsx-quotes': [2, 'prefer-single'],
|
||||||
|
'comma-dangle': [2, 'always-multiline'],
|
||||||
|
|
||||||
|
// // React
|
||||||
|
'react/jsx-boolean-value': 2,
|
||||||
|
'react/jsx-curly-spacing': [2, 'never'],
|
||||||
|
'react/jsx-equals-spacing': [2, 'never'],
|
||||||
|
// 'react/jsx-indent': 2,
|
||||||
|
'react/jsx-indent-props': [2, 2],
|
||||||
|
'react/jsx-no-duplicate-props': 2,
|
||||||
|
'react/jsx-no-undef': 2,
|
||||||
|
'react/jsx-tag-spacing': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
closingSlash: 'never',
|
||||||
|
beforeSelfClosing: 'always',
|
||||||
|
afterOpening: 'never'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'react/jsx-uses-react': 2,
|
||||||
|
'react/jsx-uses-vars': 2,
|
||||||
|
'react/self-closing-comp': 2,
|
||||||
|
'react/jsx-no-bind': [
|
||||||
|
2,
|
||||||
|
{
|
||||||
|
allowArrowFunctions: true,
|
||||||
|
allowBind: false,
|
||||||
|
ignoreRefs: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'react/no-did-update-set-state': 2,
|
||||||
|
'react/no-unknown-property': 2,
|
||||||
|
'react/react-in-jsx-scope': 2,
|
||||||
|
'react/jsx-closing-bracket-location': [2, 'tag-aligned'],
|
||||||
|
'react/jsx-tag-spacing': [2, { beforeSelfClosing: 'always' }],
|
||||||
|
'react/jsx-wrap-multilines': 2,
|
||||||
|
'react/self-closing-comp': 2,
|
||||||
|
'react/jsx-key': 2,
|
||||||
|
'react/jsx-no-comment-textnodes': 2,
|
||||||
|
'react/jsx-no-duplicate-props': 2,
|
||||||
|
'react/jsx-no-target-blank': 2,
|
||||||
|
'react/jsx-no-undef': 2,
|
||||||
|
'react/jsx-uses-react': 2,
|
||||||
|
'react/jsx-uses-vars': 2,
|
||||||
|
'react/no-danger-with-children': 2,
|
||||||
|
'react/no-deprecated': 2,
|
||||||
|
'react/no-direct-mutation-state': 2,
|
||||||
|
'react/no-find-dom-node': 2,
|
||||||
|
'react/no-is-mounted': 2,
|
||||||
|
'react/no-render-return-value': 2,
|
||||||
|
'react/no-string-refs': 2,
|
||||||
|
'react/no-unknown-property': 2,
|
||||||
|
'react/react-in-jsx-scope': 2,
|
||||||
|
'react/require-render-return': 2
|
||||||
|
// 'react/jsx-max-props-per-line': [2, { maximum: 1 }]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
lib/
|
lib/
|
||||||
|
docs/build
|
||||||
react-table.js
|
react-table.js
|
||||||
react-table.css
|
react-table.css
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
react-table.js.org
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
import React from 'react'
|
|
||||||
import { configure, storiesOf } from '@kadira/storybook'
|
|
||||||
|
|
||||||
import './reset.css'
|
|
||||||
import './fonts.css'
|
|
||||||
import './layout.css'
|
|
||||||
import '../stories/utils/prism.css'
|
|
||||||
import 'github-markdown-css/github-markdown.css'
|
|
||||||
import '../react-table.css'
|
|
||||||
//
|
|
||||||
import Readme from '../README.md'
|
|
||||||
//
|
|
||||||
import Simple from '../stories/Simple.js'
|
|
||||||
import CellRenderers from '../stories/CellRenderers.js'
|
|
||||||
import DefaultSorting from '../stories/DefaultSorting.js'
|
|
||||||
import CustomSorting from '../stories/CustomSorting.js'
|
|
||||||
import CustomWidths from '../stories/CustomWidths.js'
|
|
||||||
import CustomComponentProps from '../stories/CustomComponentProps.js'
|
|
||||||
import ServerSide from '../stories/ServerSide.js'
|
|
||||||
import SubComponents from '../stories/SubComponents.js'
|
|
||||||
import Pivoting from '../stories/Pivoting.js'
|
|
||||||
import PivotingSubComponents from '../stories/PivotingSubComponents.js'
|
|
||||||
import OneHundredKRows from '../stories/OneHundredKRows.js'
|
|
||||||
import FunctionalRendering from '../stories/FunctionalRendering.js'
|
|
||||||
import CustomExpanderPosition from '../stories/CustomExpanderPosition.js'
|
|
||||||
import NoDataText from '../stories/NoDataText.js'
|
|
||||||
import Footers from '../stories/Footers.js'
|
|
||||||
import Filtering from '../stories/Filtering.js'
|
|
||||||
import ControlledTable from '../stories/ControlledTable.js'
|
|
||||||
import PivotingOptions from '../stories/PivotingOptions.js'
|
|
||||||
import EditableTable from '../stories/EditableTable.js'
|
|
||||||
import SubRows from '../stories/SubRows.js'
|
|
||||||
//
|
|
||||||
configure(() => {
|
|
||||||
storiesOf('1. Docs')
|
|
||||||
.add('Readme', () => {
|
|
||||||
const ReadmeCmp = React.createClass({
|
|
||||||
render () {
|
|
||||||
return <span className='markdown-body' dangerouslySetInnerHTML={{__html: Readme}} />
|
|
||||||
},
|
|
||||||
componentDidMount () {
|
|
||||||
global.Prism.highlightAll()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return <ReadmeCmp />
|
|
||||||
})
|
|
||||||
storiesOf('2. Demos')
|
|
||||||
.add('Simple Table', Simple)
|
|
||||||
.add('Cell Renderers & Custom Components', CellRenderers)
|
|
||||||
.add('Default Sorting', DefaultSorting)
|
|
||||||
.add('Custom Sorting', CustomSorting)
|
|
||||||
.add('Custom Column Widths', CustomWidths)
|
|
||||||
.add('Custom Component Props', CustomComponentProps)
|
|
||||||
.add('Server-side Data', ServerSide)
|
|
||||||
.add('Sub Components', SubComponents)
|
|
||||||
.add('Pivoting & Aggregation', Pivoting)
|
|
||||||
.add('Pivoting & Aggregation w/ Sub Components', PivotingSubComponents)
|
|
||||||
.add('100k Rows w/ Pivoting & Sub Components', OneHundredKRows)
|
|
||||||
.add('Pivoting Options', PivotingOptions)
|
|
||||||
.add('Functional Rendering', FunctionalRendering)
|
|
||||||
.add('Custom Expander Position', CustomExpanderPosition)
|
|
||||||
.add('Custom "No Data" Text', NoDataText)
|
|
||||||
.add('Footers', Footers)
|
|
||||||
.add('Custom Filtering', Filtering)
|
|
||||||
.add('Controlled Component', ControlledTable)
|
|
||||||
.add('Editable table', EditableTable)
|
|
||||||
// .add('Sub Rows', SubRows)
|
|
||||||
}, module)
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,600");
|
|
||||||
body {
|
|
||||||
background: #fff;
|
|
||||||
font-family: 'Open Sans', sans-serif;
|
|
||||||
font-weight: 300;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 15px;
|
|
||||||
margin-top: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin-bottom: 15px;
|
|
||||||
line-height: 22px;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
body{
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
strong {
|
|
||||||
font-weight: bold
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/* http://meyerweb.com/eric/tools/css/reset/
|
|
||||||
v2.0 | 20110126
|
|
||||||
License: none (public domain)
|
|
||||||
*/
|
|
||||||
|
|
||||||
html, body, div, span, applet, object, iframe,
|
|
||||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
||||||
a, abbr, acronym, address, big, cite, code,
|
|
||||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
|
||||||
small, strike, strong, sub, sup, tt, var,
|
|
||||||
b, u, i, center,
|
|
||||||
dl, dt, dd, ol, ul, li,
|
|
||||||
fieldset, form, label, legend,
|
|
||||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
|
||||||
article, aside, canvas, details, embed,
|
|
||||||
figure, figcaption, footer, header, hgroup,
|
|
||||||
menu, nav, output, ruby, section, summary,
|
|
||||||
time, mark, audio, video {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
font-size: 100%;
|
|
||||||
font: inherit;
|
|
||||||
vertical-align: baseline;
|
|
||||||
}
|
|
||||||
/* HTML5 display-role reset for older browsers */
|
|
||||||
article, aside, details, figcaption, figure,
|
|
||||||
footer, header, hgroup, menu, nav, section {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
/*ol, ul {
|
|
||||||
list-style: none;
|
|
||||||
}*/
|
|
||||||
blockquote, q {
|
|
||||||
quotes: none;
|
|
||||||
}
|
|
||||||
blockquote:before, blockquote:after,
|
|
||||||
q:before, q:after {
|
|
||||||
content: '';
|
|
||||||
content: none;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
border-collapse: collapse;
|
|
||||||
border-spacing: 0;
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
const path = require('path')
|
|
||||||
|
|
||||||
// load the default config generator.
|
|
||||||
const genDefaultConfig = require('@kadira/storybook/dist/server/config/defaults/webpack.config.js')
|
|
||||||
|
|
||||||
module.exports = (config, env) => {
|
|
||||||
config = genDefaultConfig(config, env)
|
|
||||||
|
|
||||||
Object.assign(config, {
|
|
||||||
module: Object.assign(config.module, {
|
|
||||||
loaders: config.module.loaders.concat([{
|
|
||||||
test: /\.md$/,
|
|
||||||
loader: 'html!markdown',
|
|
||||||
include: path.resolve(__dirname, '../')
|
|
||||||
}, {
|
|
||||||
test: /\.html$/,
|
|
||||||
loader: 'html',
|
|
||||||
query: {
|
|
||||||
minimize: true
|
|
||||||
},
|
|
||||||
include: path.resolve(__dirname, '../')
|
|
||||||
}])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
|
## 6.4.0
|
||||||
|
##### New Features
|
||||||
|
- `PadRowComponent` - the content rendered inside of a padding row. Defaults to a react component that renders ` `
|
||||||
|
|
||||||
|
## 6.3.0
|
||||||
|
##### New Features
|
||||||
|
- `defaultSortDesc` - allows you to set the default sorting direction for all columns to descending.
|
||||||
|
- `column.defaultSortDesc` - allows you to set the default sorting direction for a specific column. Falls back to the global `defaultSortDesc` when not set at all.
|
||||||
|
|
||||||
## 6.0.0
|
## 6.0.0
|
||||||
|
|
||||||
##### New Features
|
##### New Features
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ Previous versions:
|
|||||||
|
|
||||||
## Demos and examples
|
## Demos and examples
|
||||||
- <a href="http://codepen.io/tannerlinsley/pen/QpeZBa?editors=0010" target="\_blank">Codepen</a>
|
- <a href="http://codepen.io/tannerlinsley/pen/QpeZBa?editors=0010" target="\_blank">Codepen</a>
|
||||||
- <a href="http://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Client-side%20Data&full=0&down=0&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel" target="\_parent">Storybook</a>
|
- <a href="http://react-table.js.org/#/story/simple-table" target="\_parent">Storybook</a>
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
- [Installation](#installation)
|
- [Installation](#installation)
|
||||||
@@ -155,9 +155,12 @@ These are all of the available props (and their default values) for the main `<R
|
|||||||
data: [],
|
data: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
showPagination: true,
|
showPagination: true,
|
||||||
|
showPaginationTop: false,
|
||||||
|
showPaginationBottom: true
|
||||||
showPageSizeOptions: true,
|
showPageSizeOptions: true,
|
||||||
pageSizeOptions: [5, 10, 20, 25, 50, 100],
|
pageSizeOptions: [5, 10, 20, 25, 50, 100],
|
||||||
defaultPageSize: 20,
|
defaultPageSize: 20,
|
||||||
|
minRows: undefined,
|
||||||
showPageJump: true,
|
showPageJump: true,
|
||||||
collapseOnSortingChange: true,
|
collapseOnSortingChange: true,
|
||||||
collapseOnPageChange: true,
|
collapseOnPageChange: true,
|
||||||
@@ -166,6 +169,7 @@ These are all of the available props (and their default values) for the main `<R
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
|
defaultSortDesc: false,
|
||||||
defaultSorted: [],
|
defaultSorted: [],
|
||||||
defaultFiltered: [],
|
defaultFiltered: [],
|
||||||
defaultResized: [],
|
defaultResized: [],
|
||||||
@@ -191,6 +195,7 @@ These are all of the available props (and their default values) for the main `<R
|
|||||||
// 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
|
return 0
|
||||||
},
|
},
|
||||||
|
PadRowComponent: () => <span> </span>, // the content rendered inside of a padding row
|
||||||
|
|
||||||
// Controlled State Overrides (see Fully Controlled Component section)
|
// Controlled State Overrides (see Fully Controlled Component section)
|
||||||
page: undefined,
|
page: undefined,
|
||||||
@@ -283,7 +288,8 @@ These are all of the available props (and their default values) for the main `<R
|
|||||||
footerStyle: {},
|
footerStyle: {},
|
||||||
getFooterProps: () => ({}),
|
getFooterProps: () => ({}),
|
||||||
filterMethod: undefined,
|
filterMethod: undefined,
|
||||||
sortMethod: undefined
|
sortMethod: undefined,
|
||||||
|
defaultSortDesc: undefined,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global Expander Column Defaults
|
// Global Expander Column Defaults
|
||||||
@@ -729,7 +735,7 @@ Here are the props and their corresponding callbacks that control the state of t
|
|||||||
// Props
|
// Props
|
||||||
page={0} // the index of the page you wish to display
|
page={0} // the index of the page you wish to display
|
||||||
pageSize={20} // the number of rows per page to be displayed
|
pageSize={20} // the number of rows per page to be displayed
|
||||||
sorting={[{ // the sorting model for the table
|
sorted={[{ // the sorting model for the table
|
||||||
id: 'lastName',
|
id: 'lastName',
|
||||||
desc: true
|
desc: true
|
||||||
}, {
|
}, {
|
||||||
@@ -801,7 +807,11 @@ Accessing internal state and wrapping with more UI:
|
|||||||
The possibilities are endless!
|
The possibilities are endless!
|
||||||
|
|
||||||
## Sorting
|
## Sorting
|
||||||
Sorting comes built in with React-Table. Click column header to sort by its column. Click it again to reverse the sort.
|
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`
|
||||||
|
|
||||||
## Multi-Sort
|
## Multi-Sort
|
||||||
When clicking on a column header, hold shift to multi-sort! You can toggle `ascending` `descending` and `none` for multi-sort columns. Clicking on a header without holding shift will clear the multi-sort and replace it with the single sort of that column. It's quite handy!
|
When clicking on a column header, hold shift to multi-sort! You can toggle `ascending` `descending` and `none` for multi-sort columns. Clicking on a header without holding shift will clear the multi-sort and replace it with the single sort of that column. It's quite handy!
|
||||||
@@ -821,8 +831,8 @@ defaultSortMethod = (a, b) => {
|
|||||||
a = (a === null || a === undefined) ? -Infinity : a
|
a = (a === null || a === undefined) ? -Infinity : a
|
||||||
b = (b === null || b === undefined) ? -Infinity : b
|
b = (b === null || b === undefined) ? -Infinity : b
|
||||||
// force any string values to lowercase
|
// force any string values to lowercase
|
||||||
a = a === 'string' ? a.toLowerCase() : a
|
a = typeof a === 'string' ? a.toLowerCase() : a
|
||||||
b = b === 'string' ? b.toLowerCase() : b
|
b = typeof b === 'string' ? b.toLowerCase() : b
|
||||||
// Return either 1 or -1 to indicate a sort priority
|
// Return either 1 or -1 to indicate a sort priority
|
||||||
if (a > b) {
|
if (a > b) {
|
||||||
return 1
|
return 1
|
||||||
@@ -846,7 +856,7 @@ If you want to override a particular column's filtering method, you can set the
|
|||||||
|
|
||||||
To completely override the filter that is shown, you can set the `Filter` column option. Using this option you can specify the JSX that is shown. The option is passed an `onChange` method which must be called with the the value that you wan't to pass to the `filterMethod` option whenever the filter has changed.
|
To completely override the filter that is shown, you can set the `Filter` column option. Using this option you can specify the JSX that is shown. The option is passed an `onChange` method which must be called with the the value that you wan't to pass to the `filterMethod` option whenever the filter has changed.
|
||||||
|
|
||||||
See <a href="http://react-table.js.org/?selectedKind=2.%20Demos&selectedStory=Custom%20Filtering&full=0&down=1&left=1&panelRight=0&downPanel=kadirahq%2Fstorybook-addon-actions%2Factions-panel" target="\_parent">Custom Filtering</a> demo for examples.
|
See <a href="http://react-table.js.org/#/story/custom-filtering" target="\_parent">Custom Filtering</a> demo for examples.
|
||||||
|
|
||||||
## Component Overrides
|
## Component Overrides
|
||||||
Though we confidently stand by the markup and architecture behind it, `react-table` does offer the ability to change the core componentry it uses to render everything. You can extend or override these internal components by passing a react component to it's corresponding prop on either the global props or on a one-off basis like so:
|
Though we confidently stand by the markup and architecture behind it, `react-table` does offer the ability to change the core componentry it uses to render everything. You can extend or override these internal components by passing a react component to it's corresponding prop on either the global props or on a one-off basis like so:
|
||||||
@@ -891,19 +901,18 @@ 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:
|
If you would like to help develop a suggested feature follow these steps:
|
||||||
|
|
||||||
- Fork this repo
|
- Fork this repo
|
||||||
- `$ yarn`
|
- Install dependencies with `$ yarn`
|
||||||
- `$ yarn run storybook`
|
- Auto-build files as you edit with `$ yarn run watch`
|
||||||
- Implement your changes to files in the `src/` directory
|
- Implement your changes to files in the `src/` directory
|
||||||
- View changes as you code via our <a href="https://github.com/storybooks/react-storybook" target="\_parent">React Storybook</a> `localhost:8000`
|
- Run the <a href="https://github.com/tannerlinsley/react-story">React Story</a> locally with `$ yarn run docs`
|
||||||
- Make changes to stories in `/stories`, or create a new one if needed
|
- View changes as you edit `docs/src`,
|
||||||
- Submit PR for review
|
- Submit PR for review
|
||||||
|
|
||||||
#### Scripts
|
#### Scripts
|
||||||
|
|
||||||
- `$ yarn run storybook` Runs the storybook server
|
- `$ 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 test` Runs the test suite
|
||||||
- `$ yarn run prepublish` Builds the distributable bundle
|
|
||||||
- `$ yarn run docs` Builds the website/docs from the storybook for github pages
|
|
||||||
|
|
||||||
## Used By
|
## Used By
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
react-table.js.org
|
|
||||||
+1623
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 7.1 KiB |
@@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<script>
|
|
||||||
if (window.parent !== window) {
|
|
||||||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<title>React Storybook</title>
|
|
||||||
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="root"></div>
|
|
||||||
<div id="error-display"></div>
|
|
||||||
<script src="static/preview.b8deff9f16f0debf5b04.bundle.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<meta name="storybook-version" content="2.35.3">
|
|
||||||
<title>React Storybook</title>
|
|
||||||
<style>
|
|
||||||
/*
|
|
||||||
When resizing panels, the drag event breaks if the cursor
|
|
||||||
moves over the iframe. Add the 'dragging' class to the body
|
|
||||||
at drag start and remove it when the drag ends.
|
|
||||||
*/
|
|
||||||
.dragging iframe {
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Styling the fuzzy search box placeholders */
|
|
||||||
.searchBox::-webkit-input-placeholder { /* Chrome/Opera/Safari */
|
|
||||||
color: #ddd;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.searchBox::-moz-placeholder { /* Firefox 19+ */
|
|
||||||
color: #ddd;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.searchBox:focus{
|
|
||||||
border-color: #EEE !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn:hover{
|
|
||||||
background-color: #eee
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body style="margin: 0;">
|
|
||||||
<div id="root"></div>
|
|
||||||
<script src="static/manager.4dc6928017acc8856e42.bundle.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "new",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"devDependencies": {
|
||||||
|
"react-scripts": "0.9.5",
|
||||||
|
"standard": "^10.0.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"github-markdown-css": "^2.6.0",
|
||||||
|
"marked": "^0.3.6",
|
||||||
|
"namor": "^1.0.1",
|
||||||
|
"raw-loader": "^0.5.1",
|
||||||
|
"react": "^15.5.4",
|
||||||
|
"react-dom": "^15.5.4",
|
||||||
|
"react-json-tree": "^0.10.9",
|
||||||
|
"react-story": "^0.0.10"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "react-scripts start",
|
||||||
|
"build": "react-scripts build",
|
||||||
|
"test": "react-scripts test --env=jsdom",
|
||||||
|
"eject": "react-scripts eject"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,31 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
<!--
|
||||||
|
Notice the use of %PUBLIC_URL% in the tag above.
|
||||||
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
|
||||||
|
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||||
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
|
-->
|
||||||
|
<title>React Table - A lightweight, fast and extendable datagrid built for React</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<!--
|
||||||
|
This HTML file is a template.
|
||||||
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|
||||||
|
You can add webfonts, meta tags, or analytics to this file.
|
||||||
|
The build step will place the bundled scripts into the <body> tag.
|
||||||
|
|
||||||
|
To begin the development, run `npm start`.
|
||||||
|
To create a production bundle, use `npm run build`.
|
||||||
|
-->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
import React from 'react'
|
||||||
|
//
|
||||||
|
import ReactStory, { defaultProps } from 'react-story'
|
||||||
|
|
||||||
|
import './stories/utils/prism.css'
|
||||||
|
import '../../react-table.css'
|
||||||
|
|
||||||
|
import Readme from './stories/Readme.js'
|
||||||
|
import Simple from './stories/Simple.js'
|
||||||
|
import CellRenderers from './stories/CellRenderers.js'
|
||||||
|
import DefaultSorting from './stories/DefaultSorting.js'
|
||||||
|
import CustomSorting from './stories/CustomSorting.js'
|
||||||
|
import CustomWidths from './stories/CustomWidths.js'
|
||||||
|
import CustomComponentProps from './stories/CustomComponentProps.js'
|
||||||
|
import ServerSide from './stories/ServerSide.js'
|
||||||
|
import SubComponents from './stories/SubComponents.js'
|
||||||
|
import Pivoting from './stories/Pivoting.js'
|
||||||
|
import PivotingSubComponents from './stories/PivotingSubComponents.js'
|
||||||
|
import OneHundredKRows from './stories/OneHundredKRows.js'
|
||||||
|
import FunctionalRendering from './stories/FunctionalRendering.js'
|
||||||
|
import CustomExpanderPosition from './stories/CustomExpanderPosition.js'
|
||||||
|
import NoDataText from './stories/NoDataText.js'
|
||||||
|
import Footers from './stories/Footers.js'
|
||||||
|
import Filtering from './stories/Filtering.js'
|
||||||
|
import ControlledTable from './stories/ControlledTable.js'
|
||||||
|
import PivotingOptions from './stories/PivotingOptions.js'
|
||||||
|
import EditableTable from './stories/EditableTable.js'
|
||||||
|
import FixedHeader from './stories/FixedHeader.js'
|
||||||
|
import MultiplePagers from './stories/MultiplePagers';
|
||||||
|
|
||||||
|
export default class App extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<ReactStory
|
||||||
|
style={{
|
||||||
|
display: 'block',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%'
|
||||||
|
}}
|
||||||
|
pathPrefix="story/"
|
||||||
|
StoryWrapper={props => (
|
||||||
|
<defaultProps.StoryWrapper
|
||||||
|
css={{
|
||||||
|
padding: 0
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
href="//github.com/tannerlinsley/react-table"
|
||||||
|
style={{
|
||||||
|
display: 'block',
|
||||||
|
textAlign: 'center',
|
||||||
|
borderBottom: 'solid 3px #cccccc'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src="//npmcdn.com/react-table/media/Banner.png"
|
||||||
|
alt="React Table Logo"
|
||||||
|
style={{
|
||||||
|
width: '100px'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
<div
|
||||||
|
{...props}
|
||||||
|
style={{
|
||||||
|
padding: '10px'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</defaultProps.StoryWrapper>
|
||||||
|
)}
|
||||||
|
stories={[
|
||||||
|
{ name: 'Readme', component: Readme },
|
||||||
|
{ name: 'Simple Table', component: Simple },
|
||||||
|
{
|
||||||
|
name: 'Cell Renderers & Custom Components',
|
||||||
|
component: CellRenderers
|
||||||
|
},
|
||||||
|
{ name: 'Default Sorting', component: DefaultSorting },
|
||||||
|
{ name: 'Custom Sorting', component: CustomSorting },
|
||||||
|
{ name: 'Custom Column Widths', component: CustomWidths },
|
||||||
|
{ name: 'Custom Component Props', component: CustomComponentProps },
|
||||||
|
{ name: 'Server-side Data', component: ServerSide },
|
||||||
|
{ name: 'Sub Components', component: SubComponents },
|
||||||
|
{ name: 'Pivoting & Aggregation', component: Pivoting },
|
||||||
|
{
|
||||||
|
name: 'Pivoting & Aggregation w/ Sub Components',
|
||||||
|
component: PivotingSubComponents
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '100k Rows w/ Pivoting & Sub Components',
|
||||||
|
component: OneHundredKRows
|
||||||
|
},
|
||||||
|
{ name: 'Pivoting Options', component: PivotingOptions },
|
||||||
|
{ name: 'Functional Rendering', component: FunctionalRendering },
|
||||||
|
{
|
||||||
|
name: 'Custom Expander Position',
|
||||||
|
component: CustomExpanderPosition
|
||||||
|
},
|
||||||
|
{ name: 'Custom "No Data" Text', component: NoDataText },
|
||||||
|
{ name: 'Footers', component: Footers },
|
||||||
|
{ name: 'Custom Filtering', component: Filtering },
|
||||||
|
{ name: 'Controlled Component', component: ControlledTable },
|
||||||
|
{ name: 'Editable Table', component: EditableTable },
|
||||||
|
{ name: 'Fixed Header w/ Vertical Scroll', component: FixedHeader },
|
||||||
|
{ name: 'Multiple Pagers (Top and Bottom)', component: MultiplePagers}
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
html, body, #root {
|
||||||
|
height: 100%
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import ReactDOM from 'react-dom'
|
||||||
|
//
|
||||||
|
import './index.css'
|
||||||
|
import App from './App.js'
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<App />,
|
||||||
|
document.getElementById('root')
|
||||||
|
)
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
const statusChance = Math.random()
|
const statusChance = Math.random()
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
progress: Math.floor(Math.random() * 100),
|
progress: Math.floor(Math.random() * 100),
|
||||||
status: statusChance > 0.66 ? 'relationship'
|
status: statusChance > 0.66 ? 'relationship'
|
||||||
: statusChance > 0.33 ? 'complicated'
|
: statusChance > 0.33 ? 'complicated'
|
||||||
@@ -98,7 +99,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./CellRenderers')
|
const source = require('!raw!./CellRenderers')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -30,7 +31,7 @@ const columns = [{
|
|||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
constructor () {
|
constructor () {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -78,7 +79,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./ControlledTable')
|
const source = require('!raw!./ControlledTable')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -65,7 +66,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./CustomComponentProps')
|
const source = require('!raw!./CustomComponentProps')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({words: 1, numLen: 0}),
|
firstName: namor.generate({words: 1, numbers: 0}),
|
||||||
lastName: namor.generate({words: 1, numLen: 0}),
|
lastName: namor.generate({words: 1, numbers: 0}),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -70,7 +71,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./CustomExpanderPosition')
|
const source = require('!raw!./CustomExpanderPosition')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -67,7 +68,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./CustomSorting')
|
const source = require('!raw!./CustomSorting')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -56,7 +57,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./CustomWidths')
|
const source = require('!raw!./CustomWidths')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -57,7 +58,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./DefaultSorting')
|
const source = require('!raw!./DefaultSorting')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
constructor (props, context) {
|
constructor (props, context) {
|
||||||
super(props, context)
|
super(props, context)
|
||||||
this.renderEditable = this.renderEditable.bind(this)
|
this.renderEditable = this.renderEditable.bind(this)
|
||||||
@@ -59,7 +60,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./EditableTable')
|
const source = require('!raw!./EditableTable')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import CodeHighlight from './components/codeHighlight'
|
import CodeHighlight from './components/codeHighlight'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({words: 1, numLen: 0}),
|
firstName: namor.generate({words: 1, numbers: 0}),
|
||||||
lastName: namor.generate({words: 1, numLen: 0}),
|
lastName: namor.generate({words: 1, numbers: 0}),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -87,7 +88,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={{float: 'left'}}>
|
<div>
|
||||||
<h1>Table Options</h1>
|
<h1>Table Options</h1>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -111,7 +112,7 @@ class Story extends React.Component {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div className='table-wrap' style={{paddingLeft: 240}}>
|
<div className='table-wrap'>
|
||||||
<ReactTable
|
<ReactTable
|
||||||
className='-striped -highlight'
|
className='-striped -highlight'
|
||||||
data={this.state.data}
|
data={this.state.data}
|
||||||
@@ -183,7 +184,7 @@ class Story extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const source = require('!raw-loader!./Filtering')
|
const source = require('!raw!./Filtering')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
|
import React from 'react'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import namor from 'namor'
|
||||||
|
|
||||||
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
|
class Story extends React.PureComponent {
|
||||||
|
render() {
|
||||||
|
const data = _.map(_.range(5553), d => {
|
||||||
|
return {
|
||||||
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
age: Math.floor(Math.random() * 30),
|
||||||
|
children: _.map(_.range(10), d => {
|
||||||
|
return {
|
||||||
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
age: Math.floor(Math.random() * 30)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
Header: 'Name',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
Header: 'First Name',
|
||||||
|
accessor: 'firstName'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: 'Last Name',
|
||||||
|
id: 'lastName',
|
||||||
|
accessor: d => d.lastName
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: 'Info',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
Header: 'Age',
|
||||||
|
accessor: 'age'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="table-wrap">
|
||||||
|
<ReactTable
|
||||||
|
className="-striped -highlight"
|
||||||
|
data={data}
|
||||||
|
columns={columns}
|
||||||
|
defaultPageSize={20}
|
||||||
|
style={{
|
||||||
|
height: '400px' // This will force the table body to overflow and scroll, since there is not enough room
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div style={{ textAlign: 'center' }}>
|
||||||
|
<br />
|
||||||
|
<em>Tip: Hold shift when sorting to multi-sort!</em>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
|
const source = require('!raw!./FixedHeader')
|
||||||
|
|
||||||
|
export default () => (
|
||||||
|
<div>
|
||||||
|
<Story />
|
||||||
|
<CodeHighlight>{() => source}</CodeHighlight>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -81,7 +82,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./Footers')
|
const source = require('!raw!./Footers')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
import JSONTree from 'react-json-tree'
|
import JSONTree from 'react-json-tree'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
const JSONtheme = {
|
const JSONtheme = {
|
||||||
scheme: 'monokai',
|
scheme: 'monokai',
|
||||||
@@ -26,12 +27,12 @@ const JSONtheme = {
|
|||||||
base0F: '#cc6633'
|
base0F: '#cc6633'
|
||||||
}
|
}
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -126,7 +127,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./FunctionalRendering')
|
const source = require('!raw!./FunctionalRendering')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,20 +1,21 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
children: _.map(_.range(10), d => {
|
children: _.map(_.range(10), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -47,6 +48,9 @@ class Story extends React.Component {
|
|||||||
data={data}
|
data={data}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
defaultPageSize={10}
|
defaultPageSize={10}
|
||||||
|
showPagination
|
||||||
|
showPaginationTop
|
||||||
|
showPaginationBottom
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div style={{textAlign: 'center'}}>
|
<div style={{textAlign: 'center'}}>
|
||||||
@@ -59,7 +63,7 @@ class Story extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./Simple')
|
const source = require('!raw!./MultiplePagers')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const columns = [{
|
const columns = [{
|
||||||
Header: 'Name',
|
Header: 'Name',
|
||||||
@@ -46,7 +47,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./NoDataText')
|
const source = require('!raw!./NoDataText')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(100000), d => {
|
const data = _.map(_.range(100000), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
visits: Math.floor(Math.random() * 100)
|
visits: Math.floor(Math.random() * 100)
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./OneHundredKRows')
|
const source = require('!raw!./OneHundredKRows')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(1000), d => {
|
const data = _.map(_.range(1000), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
visits: Math.floor(Math.random() * 100)
|
visits: Math.floor(Math.random() * 100)
|
||||||
}
|
}
|
||||||
@@ -63,7 +64,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./Pivoting')
|
const source = require('!raw!./Pivoting')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(1000), d => {
|
const data = _.map(_.range(1000), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({words: 1, numLen: 0}),
|
firstName: namor.generate({words: 1, numbers: 0}),
|
||||||
lastName: namor.generate({words: 1, numLen: 0}),
|
lastName: namor.generate({words: 1, numbers: 0}),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
visits: Math.floor(Math.random() * 100)
|
visits: Math.floor(Math.random() * 100)
|
||||||
}
|
}
|
||||||
@@ -121,7 +122,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./PivotingOptions')
|
const source = require('!raw!./PivotingOptions')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(1000), d => {
|
const data = _.map(_.range(1000), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
visits: Math.floor(Math.random() * 100)
|
visits: Math.floor(Math.random() * 100)
|
||||||
}
|
}
|
||||||
@@ -89,7 +90,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./PivotingSubComponents')
|
const source = require('!raw!./PivotingSubComponents')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
|
import React from 'react'
|
||||||
|
import marked from 'marked'
|
||||||
|
//
|
||||||
|
import Readme from '!raw!../../../README.md'
|
||||||
|
import 'github-markdown-css/github-markdown.css'
|
||||||
|
|
||||||
|
export default class Story extends React.Component {
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className="markdown-body"
|
||||||
|
dangerouslySetInnerHTML={{ __html: marked(Readme) }}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
componentDidMount() {
|
||||||
|
global.Prism.highlightAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
const rawData = _.map(_.range(3424), d => {
|
const rawData = _.map(_.range(3424), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -48,7 +49,7 @@ const requestData = (pageSize, page, sorted, filtered) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
constructor () {
|
constructor () {
|
||||||
super()
|
super()
|
||||||
this.state = {
|
this.state = {
|
||||||
@@ -110,7 +111,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./ServerSide')
|
const source = require('!raw!./ServerSide')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
|
import React from 'react'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import namor from 'namor'
|
||||||
|
|
||||||
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
|
class Story extends React.PureComponent {
|
||||||
|
render() {
|
||||||
|
const data = _.map(_.range(5553), d => {
|
||||||
|
return {
|
||||||
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
age: Math.floor(Math.random() * 30),
|
||||||
|
children: _.map(_.range(10), d => {
|
||||||
|
return {
|
||||||
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
|
age: Math.floor(Math.random() * 30)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
Header: 'Name',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
Header: 'First Name',
|
||||||
|
accessor: 'firstName'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: 'Last Name',
|
||||||
|
id: 'lastName',
|
||||||
|
accessor: d => d.lastName
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Header: 'Info',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
Header: 'Age',
|
||||||
|
accessor: 'age'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="table-wrap">
|
||||||
|
<ReactTable
|
||||||
|
className="-striped -highlight"
|
||||||
|
data={data}
|
||||||
|
columns={columns}
|
||||||
|
defaultPageSize={10}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div style={{ textAlign: 'center' }}>
|
||||||
|
<br />
|
||||||
|
<em>Tip: Hold shift when sorting to multi-sort!</em>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
|
const source = require('!raw!./Simple')
|
||||||
|
|
||||||
|
export default () =>
|
||||||
|
<div>
|
||||||
|
<Story />
|
||||||
|
<CodeHighlight>{() => source}</CodeHighlight>
|
||||||
|
</div>
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({words: 1, numLen: 0}),
|
firstName: namor.generate({words: 1, numbers: 0}),
|
||||||
lastName: namor.generate({words: 1, numLen: 0}),
|
lastName: namor.generate({words: 1, numbers: 0}),
|
||||||
age: Math.floor(Math.random() * 30)
|
age: Math.floor(Math.random() * 30)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -56,7 +57,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div style={{float: 'left'}}>
|
<div>
|
||||||
<h1>Table Options</h1>
|
<h1>Table Options</h1>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -80,7 +81,7 @@ class Story extends React.Component {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div className='table-wrap' style={{paddingLeft: 240}}>
|
<div className='table-wrap'>
|
||||||
<ReactTable
|
<ReactTable
|
||||||
className='-striped -highlight'
|
className='-striped -highlight'
|
||||||
data={this.state.data}
|
data={this.state.data}
|
||||||
@@ -135,7 +136,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./SubComponents')
|
const source = require('!raw!./SubComponents')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
|
/* eslint-disable import/no-webpack-loader-syntax */
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import namor from 'namor'
|
import namor from 'namor'
|
||||||
|
|
||||||
import ReactTable from '../src/index'
|
import ReactTable from '../../../lib/index'
|
||||||
|
|
||||||
class Story extends React.Component {
|
class Story extends React.PureComponent {
|
||||||
render () {
|
render () {
|
||||||
const data = _.map(_.range(5553), d => {
|
const data = _.map(_.range(5553), d => {
|
||||||
const children = _.map(_.range(10), d => {
|
const children = _.map(_.range(10), d => {
|
||||||
@@ -14,13 +15,13 @@ class Story extends React.Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
firstName: namor.generate({ words: 1, numLen: 0 }),
|
firstName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
children: grandChildren
|
children: grandChildren
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
lastName: namor.generate({ words: 1, numLen: 0 }),
|
lastName: namor.generate({ words: 1, numbers: 0 }),
|
||||||
firstName: children.map(d => d.firstName),
|
firstName: children.map(d => d.firstName),
|
||||||
age: Math.floor(Math.random() * 30),
|
age: Math.floor(Math.random() * 30),
|
||||||
children
|
children
|
||||||
@@ -67,7 +68,7 @@ class Story extends React.Component {
|
|||||||
|
|
||||||
// Source Code
|
// Source Code
|
||||||
const CodeHighlight = require('./components/codeHighlight').default
|
const CodeHighlight = require('./components/codeHighlight').default
|
||||||
const source = require('!raw-loader!./SubRows')
|
const source = require('!raw!./SubRows')
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
<div>
|
<div>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import '../utils/prism'
|
import '../utils/prism'
|
||||||
|
|
||||||
export default React.createClass({
|
export default class CodeHighlight extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { language, children } = this.props
|
const { language, children } = this.props
|
||||||
return (
|
return (
|
||||||
@@ -11,11 +11,11 @@ export default React.createClass({
|
|||||||
</code>
|
</code>
|
||||||
</pre>
|
</pre>
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
window.Prism.highlightAll()
|
window.Prism.highlightAll()
|
||||||
},
|
}
|
||||||
componentDidUpdate () {
|
componentDidUpdate () {
|
||||||
window.Prism.highlightAll()
|
window.Prism.highlightAll()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"static/manager.4dc6928017acc8856e42.bundle.js","sources":["webpack:///static/manager.4dc6928017acc8856e42.bundle.js"],"mappings":"AAAA;AAmuDA;AA64DA;AA28DA;AA00DA;AAsvEA;AAuhDA;AAsrDA;AAsiDA;AAg6DA;AA2nDA;AA++CA;AAkvDA;AAsnEA;AA2oDA;AAivCA;AA+nDA;AAkpDA;AA6lEA;AAs4DA;AAquDA;AA+pDA;AAoxDA;AAsrDA;AAkzDA;AA88GA;AAj6CA;AAopGA;AAsuFA;AA+zEA;AAtMA;AAo0EA","sourceRoot":""}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"static/preview.b8deff9f16f0debf5b04.bundle.js","sources":["webpack:///static/preview.b8deff9f16f0debf5b04.bundle.js"],"mappings":"AAAA;AAsnDA;AAg2EA;AA48EA;AA2lFA;AAmhQA;AA2/DA;AAguDA;AA8kEA;AA4xDA;AAo2DA;AAkwDA;AAunDA;AAsiDA;AA84DA;AA+nDA;AA69CA;AAunDA;AAqlEA;AA48DA;AAqgCA;AA+uDA;AAwmDA;AAiqEA;AA80DA;AAg2DA;AAwxCA;AAwqFA;AAmjGA;AA+mDA;AAk9CA;AA0xCA;AA60CA;AA8tCA;AAmmDA;AAiiBA;AAWA;AAmsEA;AAwEA;AAq9BA","sourceRoot":""}
|
|
||||||
+5783
File diff suppressed because it is too large
Load Diff
+6
-13
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-table",
|
"name": "react-table",
|
||||||
"version": "6.0.1",
|
"version": "6.4.0",
|
||||||
"description": "A fast, lightweight, opinionated table and datagrid built on React",
|
"description": "A fast, lightweight, opinionated table and datagrid built on React",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
"homepage": "https://github.com/tannerlinsley/react-table#readme",
|
||||||
@@ -34,39 +34,32 @@
|
|||||||
"build": "npm-run-all build:*",
|
"build": "npm-run-all build:*",
|
||||||
"prepublish": "npm run build && npm run umd",
|
"prepublish": "npm run build && npm run umd",
|
||||||
"postpublish": "git push --tags",
|
"postpublish": "git push --tags",
|
||||||
"storybook": "start-storybook -p 8000 -c .storybook",
|
"docs": "yarn watch & cd docs && yarn && yarn start",
|
||||||
"docs": "build-storybook -o docs && cp .storybook/CNAME docs/CNAME"
|
"docs:build": "yarn build && cd docs && yarn && yarn run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"raw-loader": "^0.5.1"
|
"react-json-tree": "^0.10.9"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^15.x.x"
|
"react": "^15.x.x"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@kadira/storybook": "^2.35.1",
|
|
||||||
"autoprefixer": "^6.7.0",
|
"autoprefixer": "^6.7.0",
|
||||||
"babel-cli": "6.14.0",
|
"babel-cli": "6.14.0",
|
||||||
"babel-eslint": "6.1.2",
|
"babel-eslint": "6.1.2",
|
||||||
"babel-preset-es2015": "6.14.0",
|
"babel-preset-es2015": "6.14.0",
|
||||||
"babel-preset-react": "6.11.1",
|
"babel-preset-react": "6.11.1",
|
||||||
"babel-preset-stage-2": "6.13.0",
|
"babel-preset-stage-2": "6.13.0",
|
||||||
"github-markdown-css": "^2.4.1",
|
|
||||||
"html-loader": "^0.4.4",
|
|
||||||
"markdown-loader": "^0.1.7",
|
|
||||||
"namor": "^0.3.0",
|
|
||||||
"npm-run-all": "^3.1.1",
|
"npm-run-all": "^3.1.1",
|
||||||
"onchange": "^3.0.2",
|
"onchange": "^3.0.2",
|
||||||
"postcss-cli": "^2.6.0",
|
"postcss-cli": "^2.6.0",
|
||||||
"react": "^15.4.2",
|
"react": "^15.4.2",
|
||||||
"react-dom": "^15.4.2",
|
"react-dom": "^15.4.2",
|
||||||
"react-json-tree": "^0.10.1",
|
|
||||||
"rimraf": "^2.6.1",
|
"rimraf": "^2.6.1",
|
||||||
"standard": "^8.0.0",
|
"standard": "^10.0.2",
|
||||||
"storybook": "^0.0.0",
|
|
||||||
"stylus": "^0.54.5",
|
"stylus": "^0.54.5",
|
||||||
"webpack": "^2.4.1"
|
"webpack": "^2.5.1"
|
||||||
},
|
},
|
||||||
"standard": {
|
"standard": {
|
||||||
"parser": "babel-eslint",
|
"parser": "babel-eslint",
|
||||||
|
|||||||
+34
-34
@@ -11,6 +11,8 @@ export default {
|
|||||||
data: [],
|
data: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
showPagination: true,
|
showPagination: true,
|
||||||
|
showPaginationTop: false,
|
||||||
|
showPaginationBottom: true,
|
||||||
showPageSizeOptions: true,
|
showPageSizeOptions: true,
|
||||||
pageSizeOptions: [5, 10, 20, 25, 50, 100],
|
pageSizeOptions: [5, 10, 20, 25, 50, 100],
|
||||||
defaultPageSize: 20,
|
defaultPageSize: 20,
|
||||||
@@ -22,18 +24,21 @@ export default {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
|
defaultSortDesc: false,
|
||||||
defaultSorted: [],
|
defaultSorted: [],
|
||||||
defaultFiltered: [],
|
defaultFiltered: [],
|
||||||
defaultResized: [],
|
defaultResized: [],
|
||||||
defaultExpanded: {},
|
defaultExpanded: {},
|
||||||
defaultFilterMethod: (filter, row, column) => {
|
defaultFilterMethod: (filter, row, column) => {
|
||||||
const id = filter.pivotId || filter.id
|
const id = filter.pivotId || filter.id
|
||||||
return row[id] !== undefined ? String(row[id]).startsWith(filter.value) : true
|
return row[id] !== undefined
|
||||||
|
? String(row[id]).startsWith(filter.value)
|
||||||
|
: true
|
||||||
},
|
},
|
||||||
defaultSortMethod: (a, b) => {
|
defaultSortMethod: (a, b) => {
|
||||||
// force null and undefined to the bottom
|
// force null and undefined to the bottom
|
||||||
a = (a === null || a === undefined) ? '' : a
|
a = a === null || a === undefined ? '' : a
|
||||||
b = (b === null || b === undefined) ? '' : b
|
b = b === null || b === undefined ? '' : b
|
||||||
// force any string values to lowercase
|
// force any string values to lowercase
|
||||||
a = typeof a === 'string' ? a.toLowerCase() : a
|
a = typeof a === 'string' ? a.toLowerCase() : a
|
||||||
b = typeof b === 'string' ? b.toLowerCase() : b
|
b = typeof b === 'string' ? b.toLowerCase() : b
|
||||||
@@ -140,7 +145,7 @@ export default {
|
|||||||
footerStyle: {},
|
footerStyle: {},
|
||||||
getFooterProps: emptyObj,
|
getFooterProps: emptyObj,
|
||||||
filterMethod: undefined,
|
filterMethod: undefined,
|
||||||
sortMethod: undefined
|
sortMethod: undefined,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Global Expander Column Defaults
|
// Global Expander Column Defaults
|
||||||
@@ -148,7 +153,7 @@ export default {
|
|||||||
sortable: false,
|
sortable: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
filterable: false,
|
filterable: false,
|
||||||
width: 35
|
width: 35,
|
||||||
},
|
},
|
||||||
|
|
||||||
pivotDefaults: {
|
pivotDefaults: {
|
||||||
@@ -170,7 +175,7 @@ export default {
|
|||||||
TbodyComponent: _.makeTemplateComponent('rt-tbody'),
|
TbodyComponent: _.makeTemplateComponent('rt-tbody'),
|
||||||
TrGroupComponent: _.makeTemplateComponent('rt-tr-group'),
|
TrGroupComponent: _.makeTemplateComponent('rt-tr-group'),
|
||||||
TrComponent: _.makeTemplateComponent('rt-tr'),
|
TrComponent: _.makeTemplateComponent('rt-tr'),
|
||||||
ThComponent: ({toggleSort, className, children, ...rest}) => {
|
ThComponent: ({ toggleSort, className, children, ...rest }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames(className, 'rt-th')}
|
className={classnames(className, 'rt-th')}
|
||||||
@@ -185,51 +190,46 @@ export default {
|
|||||||
},
|
},
|
||||||
TdComponent: _.makeTemplateComponent('rt-td'),
|
TdComponent: _.makeTemplateComponent('rt-td'),
|
||||||
TfootComponent: _.makeTemplateComponent('rt-tfoot'),
|
TfootComponent: _.makeTemplateComponent('rt-tfoot'),
|
||||||
FilterComponent: ({filter, onChange}) => (
|
FilterComponent: ({ filter, onChange }) =>
|
||||||
<input type='text'
|
<input
|
||||||
|
type='text'
|
||||||
style={{
|
style={{
|
||||||
width: '100%'
|
width: '100%',
|
||||||
}}
|
}}
|
||||||
value={filter ? filter.value : ''}
|
value={filter ? filter.value : ''}
|
||||||
onChange={(event) => onChange(event.target.value)}
|
onChange={event => onChange(event.target.value)}
|
||||||
/>
|
/>,
|
||||||
),
|
ExpanderComponent: ({ isExpanded }) =>
|
||||||
ExpanderComponent: ({isExpanded}) => (
|
|
||||||
<div className={classnames('rt-expander', isExpanded && '-open')}>
|
<div className={classnames('rt-expander', isExpanded && '-open')}>
|
||||||
•
|
•
|
||||||
</div>
|
</div>,
|
||||||
),
|
PivotValueComponent: ({ subRows, value }) =>
|
||||||
PivotValueComponent: ({subRows, value}) => (
|
<span>{value} {subRows && `(${subRows.length})`}</span>,
|
||||||
<span>{value} {subRows && `(${subRows.length})`}</span>
|
AggregatedComponent: ({ subRows, column }) => {
|
||||||
),
|
|
||||||
AggregatedComponent: ({subRows, column}) => {
|
|
||||||
const previewValues = subRows
|
const previewValues = subRows
|
||||||
.filter(d => typeof d[column.id] !== 'undefined')
|
.filter(d => typeof d[column.id] !== 'undefined')
|
||||||
.map((row, i) => (
|
.map((row, i) =>
|
||||||
<span key={i}>{row[column.id]}{i < subRows.length - 1 ? ', ' : ''}</span>
|
<span key={i}>
|
||||||
))
|
{row[column.id]}{i < subRows.length - 1 ? ', ' : ''}
|
||||||
return (
|
</span>
|
||||||
<span>{previewValues}</span>
|
)
|
||||||
)
|
return <span>{previewValues}</span>
|
||||||
},
|
},
|
||||||
PivotComponent: undefined, // this is a computed default generated using
|
PivotComponent: undefined, // this is a computed default generated using
|
||||||
// the ExpanderComponent and PivotValueComponent at run-time in methods.js
|
// the ExpanderComponent and PivotValueComponent at run-time in methods.js
|
||||||
PaginationComponent: Pagination,
|
PaginationComponent: Pagination,
|
||||||
PreviousComponent: undefined,
|
PreviousComponent: undefined,
|
||||||
NextComponent: undefined,
|
NextComponent: undefined,
|
||||||
LoadingComponent: ({className, loading, loadingText, ...rest}) => (
|
LoadingComponent: ({ className, loading, loadingText, ...rest }) =>
|
||||||
<div className={classnames(
|
<div
|
||||||
'-loading',
|
className={classnames('-loading', { '-active': loading }, className)}
|
||||||
{'-active': loading},
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<div className='-loading-inner'>
|
<div className='-loading-inner'>
|
||||||
{loadingText}
|
{loadingText}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>,
|
||||||
),
|
|
||||||
NoDataComponent: _.makeTemplateComponent('rt-noData'),
|
NoDataComponent: _.makeTemplateComponent('rt-noData'),
|
||||||
ResizerComponent: _.makeTemplateComponent('rt-resizer')
|
ResizerComponent: _.makeTemplateComponent('rt-resizer'),
|
||||||
|
PadRowComponent: () => <span> </span>,
|
||||||
}
|
}
|
||||||
|
|||||||
+356
-205
@@ -11,7 +11,7 @@ export const ReactTableDefaults = defaultProps
|
|||||||
export default class ReactTable extends Methods(Lifecycle(Component)) {
|
export default class ReactTable extends Methods(Lifecycle(Component)) {
|
||||||
static defaultProps = defaultProps
|
static defaultProps = defaultProps
|
||||||
|
|
||||||
constructor (props) {
|
constructor(props) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.getResolvedState = this.getResolvedState.bind(this)
|
this.getResolvedState = this.getResolvedState.bind(this)
|
||||||
@@ -43,7 +43,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render() {
|
||||||
const resolvedState = this.getResolvedState()
|
const resolvedState = this.getResolvedState()
|
||||||
const {
|
const {
|
||||||
children,
|
children,
|
||||||
@@ -72,6 +72,8 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
getNoDataProps,
|
getNoDataProps,
|
||||||
getResizerProps,
|
getResizerProps,
|
||||||
showPagination,
|
showPagination,
|
||||||
|
showPaginationTop,
|
||||||
|
showPaginationBottom,
|
||||||
manual,
|
manual,
|
||||||
loadingText,
|
loadingText,
|
||||||
noDataText,
|
noDataText,
|
||||||
@@ -116,6 +118,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
PivotComponent,
|
PivotComponent,
|
||||||
AggregatedComponent,
|
AggregatedComponent,
|
||||||
FilterComponent,
|
FilterComponent,
|
||||||
|
PadRowComponent,
|
||||||
// Data model
|
// Data model
|
||||||
resolvedData,
|
resolvedData,
|
||||||
allVisibleColumns,
|
allVisibleColumns,
|
||||||
@@ -146,23 +149,28 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
const newPath = path.concat([i])
|
const newPath = path.concat([i])
|
||||||
if (rowWithViewIndex[subRowsKey] && _.get(expanded, newPath)) {
|
if (rowWithViewIndex[subRowsKey] && _.get(expanded, newPath)) {
|
||||||
[rowWithViewIndex[subRowsKey], index] = recurseRowsViewIndex(rowWithViewIndex[subRowsKey], newPath, index)
|
;[rowWithViewIndex[subRowsKey], index] = recurseRowsViewIndex(
|
||||||
|
rowWithViewIndex[subRowsKey],
|
||||||
|
newPath,
|
||||||
|
index
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return rowWithViewIndex
|
return rowWithViewIndex
|
||||||
}),
|
}),
|
||||||
index
|
index
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
;[pageRows] = recurseRowsViewIndex(pageRows)
|
||||||
[pageRows] = recurseRowsViewIndex(pageRows)
|
|
||||||
|
|
||||||
const canPrevious = page > 0
|
const canPrevious = page > 0
|
||||||
const canNext = page + 1 < pages
|
const canNext = page + 1 < pages
|
||||||
|
|
||||||
const rowMinWidth = _.sum(allVisibleColumns.map(d => {
|
const rowMinWidth = _.sum(
|
||||||
const resizedColumn = resized.find(x => x.id === d.id) || {}
|
allVisibleColumns.map(d => {
|
||||||
return _.getFirstDefined(resizedColumn.value, d.width, d.minWidth)
|
const resizedColumn = resized.find(x => x.id === d.id) || {}
|
||||||
}))
|
return _.getFirstDefined(resizedColumn.value, d.width, d.minWidth)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
let rowIndex = -1
|
let rowIndex = -1
|
||||||
|
|
||||||
@@ -182,8 +190,12 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
// Visual Components
|
// Visual Components
|
||||||
|
|
||||||
const makeHeaderGroups = () => {
|
const makeHeaderGroups = () => {
|
||||||
const theadGroupProps = _.splitProps(getTheadGroupProps(finalState, undefined, undefined, this))
|
const theadGroupProps = _.splitProps(
|
||||||
const theadGroupTrProps = _.splitProps(getTheadGroupTrProps(finalState, undefined, undefined, this))
|
getTheadGroupProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
|
const theadGroupTrProps = _.splitProps(
|
||||||
|
getTheadGroupTrProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<TheadComponent
|
<TheadComponent
|
||||||
className={classnames('-headerGroups', theadGroupProps.className)}
|
className={classnames('-headerGroups', theadGroupProps.className)}
|
||||||
@@ -205,13 +217,30 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const makeHeaderGroup = (column, i) => {
|
const makeHeaderGroup = (column, i) => {
|
||||||
const resizedValue = col => (resized.find(x => x.id === col.id) || {}).value
|
const resizedValue = col =>
|
||||||
const flex = _.sum(column.columns.map(col => col.width || resizedValue(col) ? 0 : col.minWidth))
|
(resized.find(x => x.id === col.id) || {}).value
|
||||||
const width = _.sum(column.columns.map(col => _.getFirstDefined(resizedValue(col), col.width, col.minWidth)))
|
const flex = _.sum(
|
||||||
const maxWidth = _.sum(column.columns.map(col => _.getFirstDefined(resizedValue(col), col.width, col.maxWidth)))
|
column.columns.map(
|
||||||
|
col => (col.width || resizedValue(col) ? 0 : col.minWidth)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const width = _.sum(
|
||||||
|
column.columns.map(col =>
|
||||||
|
_.getFirstDefined(resizedValue(col), col.width, col.minWidth)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
const maxWidth = _.sum(
|
||||||
|
column.columns.map(col =>
|
||||||
|
_.getFirstDefined(resizedValue(col), col.width, col.maxWidth)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
const theadGroupThProps = _.splitProps(getTheadGroupThProps(finalState, undefined, column, this))
|
const theadGroupThProps = _.splitProps(
|
||||||
const columnHeaderProps = _.splitProps(column.getHeaderProps(finalState, undefined, column, this))
|
getTheadGroupThProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
const columnHeaderProps = _.splitProps(
|
||||||
|
column.getHeaderProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
column.headerClassName,
|
column.headerClassName,
|
||||||
@@ -239,9 +268,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
return (
|
return (
|
||||||
<ThComponent
|
<ThComponent
|
||||||
key={i + '-' + column.id}
|
key={i + '-' + column.id}
|
||||||
className={classnames(
|
className={classnames(classes)}
|
||||||
classes
|
|
||||||
)}
|
|
||||||
style={{
|
style={{
|
||||||
...styles,
|
...styles,
|
||||||
...flexStyles
|
...flexStyles
|
||||||
@@ -257,8 +284,12 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const makeHeaders = () => {
|
const makeHeaders = () => {
|
||||||
const theadProps = _.splitProps(getTheadProps(finalState, undefined, undefined, this))
|
const theadProps = _.splitProps(
|
||||||
const theadTrProps = _.splitProps(getTheadTrProps(finalState, undefined, undefined, this))
|
getTheadProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
|
const theadTrProps = _.splitProps(
|
||||||
|
getTheadTrProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<TheadComponent
|
<TheadComponent
|
||||||
className={classnames('-header', theadProps.className)}
|
className={classnames('-header', theadProps.className)}
|
||||||
@@ -282,11 +313,25 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
const makeHeader = (column, i) => {
|
const makeHeader = (column, i) => {
|
||||||
const resizedCol = resized.find(x => x.id === column.id) || {}
|
const resizedCol = resized.find(x => x.id === column.id) || {}
|
||||||
const sort = sorted.find(d => d.id === column.id)
|
const sort = sorted.find(d => d.id === column.id)
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function'
|
||||||
const width = _.getFirstDefined(resizedCol.value, column.width, column.minWidth)
|
? column.show()
|
||||||
const maxWidth = _.getFirstDefined(resizedCol.value, column.width, column.maxWidth)
|
: column.show
|
||||||
const theadThProps = _.splitProps(getTheadThProps(finalState, undefined, column, this))
|
const width = _.getFirstDefined(
|
||||||
const columnHeaderProps = _.splitProps(column.getHeaderProps(finalState, undefined, column, this))
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.minWidth
|
||||||
|
)
|
||||||
|
const maxWidth = _.getFirstDefined(
|
||||||
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.maxWidth
|
||||||
|
)
|
||||||
|
const theadThProps = _.splitProps(
|
||||||
|
getTheadThProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
const columnHeaderProps = _.splitProps(
|
||||||
|
column.getHeaderProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
column.headerClassName,
|
column.headerClassName,
|
||||||
@@ -306,14 +351,13 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isResizable = _.getFirstDefined(column.resizable, resizable, false)
|
const isResizable = _.getFirstDefined(column.resizable, resizable, false)
|
||||||
const resizer = isResizable ? (
|
const resizer = isResizable
|
||||||
<ResizerComponent
|
? <ResizerComponent
|
||||||
onMouseDown={e => this.resizeColumnStart(column, e, false)}
|
onMouseDown={e => this.resizeColumnStart(column, e, false)}
|
||||||
onTouchStart={e => this.resizeColumnStart(column, e, true)}
|
onTouchStart={e => this.resizeColumnStart(column, e, true)}
|
||||||
|
{...resizerProps}
|
||||||
{...resizerProps}
|
/>
|
||||||
/>
|
: null
|
||||||
) : null
|
|
||||||
|
|
||||||
const isSortable = _.getFirstDefined(column.sortable, sortable, false)
|
const isSortable = _.getFirstDefined(column.sortable, sortable, false)
|
||||||
|
|
||||||
@@ -326,7 +370,9 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
sort ? (sort.desc ? '-sort-desc' : '-sort-asc') : '',
|
sort ? (sort.desc ? '-sort-desc' : '-sort-asc') : '',
|
||||||
isSortable && '-cursor-pointer',
|
isSortable && '-cursor-pointer',
|
||||||
!show && '-hidden',
|
!show && '-hidden',
|
||||||
pivotBy && pivotBy.slice(0, -1).includes(column.id) && 'rt-header-pivot'
|
pivotBy &&
|
||||||
|
pivotBy.slice(0, -1).includes(column.id) &&
|
||||||
|
'rt-header-pivot'
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
...styles,
|
...styles,
|
||||||
@@ -334,12 +380,12 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
width: `${width}px`,
|
width: `${width}px`,
|
||||||
maxWidth: `${maxWidth}px`
|
maxWidth: `${maxWidth}px`
|
||||||
}}
|
}}
|
||||||
toggleSort={(e) => {
|
toggleSort={e => {
|
||||||
isSortable && this.sortColumn(column, e.shiftKey)
|
isSortable && this.sortColumn(column, e.shiftKey)
|
||||||
}}
|
}}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
<div className='rt-resizable-header-content'>
|
<div className="rt-resizable-header-content">
|
||||||
{_.normalizeComponent(column.Header, {
|
{_.normalizeComponent(column.Header, {
|
||||||
data: sortedData,
|
data: sortedData,
|
||||||
column: column
|
column: column
|
||||||
@@ -351,8 +397,12 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const makeFilters = () => {
|
const makeFilters = () => {
|
||||||
const theadFilterProps = _.splitProps(getTheadFilterProps(finalState, undefined, undefined, this))
|
const theadFilterProps = _.splitProps(
|
||||||
const theadFilterTrProps = _.splitProps(getTheadFilterTrProps(finalState, undefined, undefined, this))
|
getTheadFilterProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
|
const theadFilterTrProps = _.splitProps(
|
||||||
|
getTheadFilterTrProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<TheadComponent
|
<TheadComponent
|
||||||
className={classnames('-filters', theadFilterProps.className)}
|
className={classnames('-filters', theadFilterProps.className)}
|
||||||
@@ -375,10 +425,22 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
|
|
||||||
const makeFilter = (column, i) => {
|
const makeFilter = (column, i) => {
|
||||||
const resizedCol = resized.find(x => x.id === column.id) || {}
|
const resizedCol = resized.find(x => x.id === column.id) || {}
|
||||||
const width = _.getFirstDefined(resizedCol.value, column.width, column.minWidth)
|
const width = _.getFirstDefined(
|
||||||
const maxWidth = _.getFirstDefined(resizedCol.value, column.width, column.maxWidth)
|
resizedCol.value,
|
||||||
const theadFilterThProps = _.splitProps(getTheadFilterThProps(finalState, undefined, column, this))
|
column.width,
|
||||||
const columnHeaderProps = _.splitProps(column.getHeaderProps(finalState, undefined, column, this))
|
column.minWidth
|
||||||
|
)
|
||||||
|
const maxWidth = _.getFirstDefined(
|
||||||
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.maxWidth
|
||||||
|
)
|
||||||
|
const theadFilterThProps = _.splitProps(
|
||||||
|
getTheadFilterThProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
const columnHeaderProps = _.splitProps(
|
||||||
|
column.getHeaderProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
column.headerClassName,
|
column.headerClassName,
|
||||||
@@ -401,14 +463,16 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
|
|
||||||
const ResolvedFilterComponent = column.Filter || FilterComponent
|
const ResolvedFilterComponent = column.Filter || FilterComponent
|
||||||
|
|
||||||
const isFilterable = _.getFirstDefined(column.filterable, filterable, false)
|
const isFilterable = _.getFirstDefined(
|
||||||
|
column.filterable,
|
||||||
|
filterable,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThComponent
|
<ThComponent
|
||||||
key={i + '-' + column.id}
|
key={i + '-' + column.id}
|
||||||
className={classnames(
|
className={classnames(classes)}
|
||||||
classes
|
|
||||||
)}
|
|
||||||
style={{
|
style={{
|
||||||
...styles,
|
...styles,
|
||||||
flex: `${width} 0 auto`,
|
flex: `${width} 0 auto`,
|
||||||
@@ -417,16 +481,17 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}}
|
}}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{isFilterable ? (
|
{isFilterable
|
||||||
_.normalizeComponent(ResolvedFilterComponent,
|
? _.normalizeComponent(
|
||||||
{
|
ResolvedFilterComponent,
|
||||||
column,
|
{
|
||||||
filter,
|
column,
|
||||||
onChange: (value) => (this.filterColumn(column, value))
|
filter,
|
||||||
},
|
onChange: value => this.filterColumn(column, value)
|
||||||
defaultProps.column.Filter
|
},
|
||||||
)
|
defaultProps.column.Filter
|
||||||
) : null}
|
)
|
||||||
|
: null}
|
||||||
</ThComponent>
|
</ThComponent>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -445,12 +510,11 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}
|
}
|
||||||
const isExpanded = _.get(expanded, rowInfo.nestingPath)
|
const isExpanded = _.get(expanded, rowInfo.nestingPath)
|
||||||
const trGroupProps = getTrGroupProps(finalState, rowInfo, undefined, this)
|
const trGroupProps = getTrGroupProps(finalState, rowInfo, undefined, this)
|
||||||
const trProps = _.splitProps(getTrProps(finalState, rowInfo, undefined, this))
|
const trProps = _.splitProps(
|
||||||
|
getTrProps(finalState, rowInfo, undefined, this)
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<TrGroupComponent
|
<TrGroupComponent key={rowInfo.nestingPath.join('_')} {...trGroupProps}>
|
||||||
key={rowInfo.nestingPath.join('_')}
|
|
||||||
{...trGroupProps}
|
|
||||||
>
|
|
||||||
<TrComponent
|
<TrComponent
|
||||||
className={classnames(
|
className={classnames(
|
||||||
trProps.className,
|
trProps.className,
|
||||||
@@ -461,11 +525,25 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
>
|
>
|
||||||
{allVisibleColumns.map((column, i2) => {
|
{allVisibleColumns.map((column, i2) => {
|
||||||
const resizedCol = resized.find(x => x.id === column.id) || {}
|
const resizedCol = resized.find(x => x.id === column.id) || {}
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function'
|
||||||
const width = _.getFirstDefined(resizedCol.value, column.width, column.minWidth)
|
? column.show()
|
||||||
const maxWidth = _.getFirstDefined(resizedCol.value, column.width, column.maxWidth)
|
: column.show
|
||||||
const tdProps = _.splitProps(getTdProps(finalState, rowInfo, column, this))
|
const width = _.getFirstDefined(
|
||||||
const columnProps = _.splitProps(column.getProps(finalState, rowInfo, column, this))
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.minWidth
|
||||||
|
)
|
||||||
|
const maxWidth = _.getFirstDefined(
|
||||||
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.maxWidth
|
||||||
|
)
|
||||||
|
const tdProps = _.splitProps(
|
||||||
|
getTdProps(finalState, rowInfo, column, this)
|
||||||
|
)
|
||||||
|
const columnProps = _.splitProps(
|
||||||
|
column.getProps(finalState, rowInfo, column, this)
|
||||||
|
)
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
tdProps.className,
|
tdProps.className,
|
||||||
@@ -482,7 +560,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
const cellInfo = {
|
const cellInfo = {
|
||||||
...rowInfo,
|
...rowInfo,
|
||||||
isExpanded,
|
isExpanded,
|
||||||
column: {...column},
|
column: { ...column },
|
||||||
value: rowInfo.row[column.id],
|
value: rowInfo.row[column.id],
|
||||||
pivoted: column.pivoted,
|
pivoted: column.pivoted,
|
||||||
expander: column.expander,
|
expander: column.expander,
|
||||||
@@ -502,41 +580,49 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
let isBranch
|
let isBranch
|
||||||
let isPreview
|
let isPreview
|
||||||
|
|
||||||
const onExpanderClick = (e) => {
|
const onExpanderClick = e => {
|
||||||
let newExpanded = _.clone(expanded)
|
let newExpanded = _.clone(expanded)
|
||||||
if (isExpanded) {
|
if (isExpanded) {
|
||||||
newExpanded = _.set(newExpanded, cellInfo.nestingPath, false)
|
newExpanded = _.set(newExpanded, cellInfo.nestingPath, false)
|
||||||
} else {
|
} else {
|
||||||
newExpanded = _.set(newExpanded, cellInfo.nestingPath, {})
|
newExpanded = _.set(newExpanded, cellInfo.nestingPath, {})
|
||||||
}
|
}
|
||||||
if (onExpandedChange) {
|
|
||||||
onExpandedChange(newExpanded, cellInfo.nestingPath, e)
|
return this.setStateWithData(
|
||||||
}
|
{
|
||||||
// If expanded is being controlled, don't manage internal state
|
expanded: newExpanded
|
||||||
if (this.props.expanded) {
|
},
|
||||||
return
|
() => {
|
||||||
}
|
onExpandedChange &&
|
||||||
return this.setStateWithData({
|
onExpandedChange(newExpanded, cellInfo.nestingPath, e)
|
||||||
expanded: newExpanded
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to a standard cell
|
// Default to a standard cell
|
||||||
let resolvedCell = _.normalizeComponent(column.Cell, cellInfo, value)
|
let resolvedCell = _.normalizeComponent(
|
||||||
|
column.Cell,
|
||||||
|
cellInfo,
|
||||||
|
value
|
||||||
|
)
|
||||||
|
|
||||||
// Resolve Renderers
|
// Resolve Renderers
|
||||||
const ResolvedAggregatedComponent = column.Aggregated || (!column.aggregate ? AggregatedComponent : column.Cell)
|
const ResolvedAggregatedComponent =
|
||||||
const ResolvedExpanderComponent = column.Expander || ExpanderComponent
|
column.Aggregated ||
|
||||||
const ResolvedPivotValueComponent = column.PivotValue || PivotValueComponent
|
(!column.aggregate ? AggregatedComponent : column.Cell)
|
||||||
const DefaultResolvedPivotComponent = PivotComponent || (
|
const ResolvedExpanderComponent =
|
||||||
props => (
|
column.Expander || ExpanderComponent
|
||||||
<div>
|
const ResolvedPivotValueComponent =
|
||||||
<ResolvedExpanderComponent {...props} />
|
column.PivotValue || PivotValueComponent
|
||||||
<ResolvedPivotValueComponent {...props} />
|
const DefaultResolvedPivotComponent =
|
||||||
</div>
|
PivotComponent ||
|
||||||
)
|
(props =>
|
||||||
)
|
<div>
|
||||||
const ResolvedPivotComponent = column.Pivot || DefaultResolvedPivotComponent
|
<ResolvedExpanderComponent {...props} />
|
||||||
|
<ResolvedPivotValueComponent {...props} />
|
||||||
|
</div>)
|
||||||
|
const ResolvedPivotComponent =
|
||||||
|
column.Pivot || DefaultResolvedPivotComponent
|
||||||
|
|
||||||
// Is this cell expandable?
|
// Is this cell expandable?
|
||||||
if (cellInfo.pivoted || cellInfo.expander) {
|
if (cellInfo.pivoted || cellInfo.expander) {
|
||||||
@@ -558,30 +644,47 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
|
|
||||||
if (cellInfo.pivoted) {
|
if (cellInfo.pivoted) {
|
||||||
// Is this column a branch?
|
// Is this column a branch?
|
||||||
isBranch = rowInfo.row[pivotIDKey] === column.id &&
|
isBranch =
|
||||||
cellInfo.subRows
|
rowInfo.row[pivotIDKey] === column.id && cellInfo.subRows
|
||||||
// Should this column be blank?
|
// Should this column be blank?
|
||||||
isPreview = pivotBy.indexOf(column.id) > pivotBy.indexOf(rowInfo.row[pivotIDKey]) &&
|
isPreview =
|
||||||
cellInfo.subRows
|
pivotBy.indexOf(column.id) >
|
||||||
|
pivotBy.indexOf(rowInfo.row[pivotIDKey]) && cellInfo.subRows
|
||||||
// Pivot Cell Render Override
|
// Pivot Cell Render Override
|
||||||
if (isBranch) {
|
if (isBranch) {
|
||||||
// isPivot
|
// isPivot
|
||||||
resolvedCell = _.normalizeComponent(ResolvedPivotComponent, {
|
resolvedCell = _.normalizeComponent(
|
||||||
...cellInfo,
|
ResolvedPivotComponent,
|
||||||
value: row[pivotValKey]
|
{
|
||||||
}, row[pivotValKey])
|
...cellInfo,
|
||||||
|
value: row[pivotValKey]
|
||||||
|
},
|
||||||
|
row[pivotValKey]
|
||||||
|
)
|
||||||
} else if (isPreview) {
|
} else if (isPreview) {
|
||||||
// Show the pivot preview
|
// Show the pivot preview
|
||||||
resolvedCell = _.normalizeComponent(ResolvedAggregatedComponent, cellInfo, value)
|
resolvedCell = _.normalizeComponent(
|
||||||
|
ResolvedAggregatedComponent,
|
||||||
|
cellInfo,
|
||||||
|
value
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
resolvedCell = null
|
resolvedCell = null
|
||||||
}
|
}
|
||||||
} else if (cellInfo.aggregated) {
|
} else if (cellInfo.aggregated) {
|
||||||
resolvedCell = _.normalizeComponent(ResolvedAggregatedComponent, cellInfo, value)
|
resolvedCell = _.normalizeComponent(
|
||||||
|
ResolvedAggregatedComponent,
|
||||||
|
cellInfo,
|
||||||
|
value
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cellInfo.expander) {
|
if (cellInfo.expander) {
|
||||||
resolvedCell = _.normalizeComponent(ResolvedExpanderComponent, cellInfo, row[pivotValKey])
|
resolvedCell = _.normalizeComponent(
|
||||||
|
ResolvedExpanderComponent,
|
||||||
|
cellInfo,
|
||||||
|
row[pivotValKey]
|
||||||
|
)
|
||||||
if (pivotBy) {
|
if (pivotBy) {
|
||||||
if (cellInfo.groupedByPivot) {
|
if (cellInfo.groupedByPivot) {
|
||||||
resolvedCell = null
|
resolvedCell = null
|
||||||
@@ -616,29 +719,36 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</TrComponent>
|
</TrComponent>
|
||||||
{(
|
{rowInfo.subRows &&
|
||||||
rowInfo.subRows &&
|
|
||||||
isExpanded &&
|
isExpanded &&
|
||||||
rowInfo.subRows.map((d, i) => makePageRow(d, i, rowInfo.nestingPath))
|
rowInfo.subRows.map((d, i) =>
|
||||||
)}
|
makePageRow(d, i, rowInfo.nestingPath)
|
||||||
{SubComponent && !rowInfo.subRows && isExpanded && SubComponent(rowInfo)}
|
)}
|
||||||
|
{SubComponent &&
|
||||||
|
!rowInfo.subRows &&
|
||||||
|
isExpanded &&
|
||||||
|
SubComponent(rowInfo)}
|
||||||
</TrGroupComponent>
|
</TrGroupComponent>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const makePadRow = (row, i) => {
|
const makePadRow = (row, i) => {
|
||||||
const trGroupProps = getTrGroupProps(finalState, undefined, undefined, this)
|
const trGroupProps = getTrGroupProps(
|
||||||
const trProps = _.splitProps(getTrProps(finalState, undefined, undefined, this))
|
finalState,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
this
|
||||||
|
)
|
||||||
|
const trProps = _.splitProps(
|
||||||
|
getTrProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<TrGroupComponent
|
<TrGroupComponent key={i} {...trGroupProps}>
|
||||||
key={i}
|
|
||||||
{...trGroupProps}
|
|
||||||
>
|
|
||||||
<TrComponent
|
<TrComponent
|
||||||
className={classnames(
|
className={classnames(
|
||||||
'-padRow',
|
'-padRow',
|
||||||
(pageRows.length + i) % 2 ? '-even' : '-odd',
|
(pageRows.length + i) % 2 ? '-even' : '-odd',
|
||||||
trProps.className,
|
trProps.className
|
||||||
)}
|
)}
|
||||||
style={trProps.style || {}}
|
style={trProps.style || {}}
|
||||||
>
|
>
|
||||||
@@ -650,12 +760,26 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
|
|
||||||
const makePadColumn = (column, i) => {
|
const makePadColumn = (column, i) => {
|
||||||
const resizedCol = resized.find(x => x.id === column.id) || {}
|
const resizedCol = resized.find(x => x.id === column.id) || {}
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function'
|
||||||
let width = _.getFirstDefined(resizedCol.value, column.width, column.minWidth)
|
? column.show()
|
||||||
|
: column.show
|
||||||
|
let width = _.getFirstDefined(
|
||||||
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.minWidth
|
||||||
|
)
|
||||||
let flex = width
|
let flex = width
|
||||||
let maxWidth = _.getFirstDefined(resizedCol.value, column.width, column.maxWidth)
|
let maxWidth = _.getFirstDefined(
|
||||||
const tdProps = _.splitProps(getTdProps(finalState, undefined, column, this))
|
resizedCol.value,
|
||||||
const columnProps = _.splitProps(column.getProps(finalState, undefined, column, this))
|
column.width,
|
||||||
|
column.maxWidth
|
||||||
|
)
|
||||||
|
const tdProps = _.splitProps(
|
||||||
|
getTdProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
const columnProps = _.splitProps(
|
||||||
|
column.getProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
tdProps.className,
|
tdProps.className,
|
||||||
@@ -672,10 +796,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
return (
|
return (
|
||||||
<TdComponent
|
<TdComponent
|
||||||
key={i + '-' + column.id}
|
key={i + '-' + column.id}
|
||||||
className={classnames(
|
className={classnames(classes, !show && 'hidden')}
|
||||||
classes,
|
|
||||||
!show && 'hidden'
|
|
||||||
)}
|
|
||||||
style={{
|
style={{
|
||||||
...styles,
|
...styles,
|
||||||
flex: `${flex} 0 auto`,
|
flex: `${flex} 0 auto`,
|
||||||
@@ -684,14 +805,16 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
}}
|
}}
|
||||||
{...tdProps.rest}
|
{...tdProps.rest}
|
||||||
>
|
>
|
||||||
|
{_.normalizeComponent(PadRowComponent)}
|
||||||
</TdComponent>
|
</TdComponent>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeColumnFooters = () => {
|
const makeColumnFooters = () => {
|
||||||
const tFootProps = getTfootProps(finalState, undefined, undefined, this)
|
const tFootProps = getTfootProps(finalState, undefined, undefined, this)
|
||||||
const tFootTrProps = _.splitProps(getTfootTrProps(finalState, undefined, undefined, this))
|
const tFootTrProps = _.splitProps(
|
||||||
|
getTfootTrProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<TfootComponent
|
<TfootComponent
|
||||||
className={tFootProps.className}
|
className={tFootProps.className}
|
||||||
@@ -702,9 +825,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
{...tFootProps.rest}
|
{...tFootProps.rest}
|
||||||
>
|
>
|
||||||
<TrComponent
|
<TrComponent
|
||||||
className={classnames(
|
className={classnames(tFootTrProps.className)}
|
||||||
tFootTrProps.className
|
|
||||||
)}
|
|
||||||
style={tFootTrProps.style}
|
style={tFootTrProps.style}
|
||||||
{...tFootTrProps.rest}
|
{...tFootTrProps.rest}
|
||||||
>
|
>
|
||||||
@@ -716,12 +837,28 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
|
|
||||||
const makeColumnFooter = (column, i) => {
|
const makeColumnFooter = (column, i) => {
|
||||||
const resizedCol = resized.find(x => x.id === column.id) || {}
|
const resizedCol = resized.find(x => x.id === column.id) || {}
|
||||||
const show = typeof column.show === 'function' ? column.show() : column.show
|
const show = typeof column.show === 'function'
|
||||||
const width = _.getFirstDefined(resizedCol.value, column.width, column.minWidth)
|
? column.show()
|
||||||
const maxWidth = _.getFirstDefined(resizedCol.value, column.width, column.maxWidth)
|
: column.show
|
||||||
const tFootTdProps = _.splitProps(getTfootTdProps(finalState, undefined, undefined, this))
|
const width = _.getFirstDefined(
|
||||||
const columnProps = _.splitProps(column.getProps(finalState, undefined, column, this))
|
resizedCol.value,
|
||||||
const columnFooterProps = _.splitProps(column.getFooterProps(finalState, undefined, column, this))
|
column.width,
|
||||||
|
column.minWidth
|
||||||
|
)
|
||||||
|
const maxWidth = _.getFirstDefined(
|
||||||
|
resizedCol.value,
|
||||||
|
column.width,
|
||||||
|
column.maxWidth
|
||||||
|
)
|
||||||
|
const tFootTdProps = _.splitProps(
|
||||||
|
getTfootTdProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
|
const columnProps = _.splitProps(
|
||||||
|
column.getProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
const columnFooterProps = _.splitProps(
|
||||||
|
column.getFooterProps(finalState, undefined, column, this)
|
||||||
|
)
|
||||||
|
|
||||||
const classes = [
|
const classes = [
|
||||||
tFootTdProps.className,
|
tFootTdProps.className,
|
||||||
@@ -740,10 +877,7 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
return (
|
return (
|
||||||
<TdComponent
|
<TdComponent
|
||||||
key={i + '-' + column.id}
|
key={i + '-' + column.id}
|
||||||
className={classnames(
|
className={classnames(classes, !show && 'hidden')}
|
||||||
classes,
|
|
||||||
!show && 'hidden'
|
|
||||||
)}
|
|
||||||
style={{
|
style={{
|
||||||
...styles,
|
...styles,
|
||||||
flex: `${width} 0 auto`,
|
flex: `${width} 0 auto`,
|
||||||
@@ -762,78 +896,95 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootProps = _.splitProps(getProps(finalState, undefined, undefined, this))
|
const makePagination = () => {
|
||||||
const tableProps = _.splitProps(getTableProps(finalState, undefined, undefined, this))
|
const paginationProps = _.splitProps(
|
||||||
const tBodyProps = _.splitProps(getTbodyProps(finalState, undefined, undefined, this))
|
getPaginationProps(finalState, undefined, undefined, this)
|
||||||
const paginationProps = _.splitProps(getPaginationProps(finalState, undefined, undefined, this))
|
)
|
||||||
|
return (
|
||||||
|
<PaginationComponent
|
||||||
|
{...resolvedState}
|
||||||
|
pages={pages}
|
||||||
|
canPrevious={canPrevious}
|
||||||
|
canNext={canNext}
|
||||||
|
onPageChange={this.onPageChange}
|
||||||
|
onPageSizeChange={this.onPageSizeChange}
|
||||||
|
className={paginationProps.className}
|
||||||
|
style={paginationProps.style}
|
||||||
|
{...paginationProps.rest}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const rootProps = _.splitProps(
|
||||||
|
getProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
|
const tableProps = _.splitProps(
|
||||||
|
getTableProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
|
const tBodyProps = _.splitProps(
|
||||||
|
getTbodyProps(finalState, undefined, undefined, this)
|
||||||
|
)
|
||||||
const loadingProps = getLoadingProps(finalState, undefined, undefined, this)
|
const loadingProps = getLoadingProps(finalState, undefined, undefined, this)
|
||||||
const noDataProps = getNoDataProps(finalState, undefined, undefined, this)
|
const noDataProps = getNoDataProps(finalState, undefined, undefined, this)
|
||||||
const resizerProps = getResizerProps(finalState, undefined, undefined, this)
|
const resizerProps = getResizerProps(finalState, undefined, undefined, this)
|
||||||
|
|
||||||
const makeTable = () => (
|
const makeTable = () => {
|
||||||
<div
|
const pagination = makePagination()
|
||||||
className={classnames(
|
return (
|
||||||
'ReactTable',
|
<div
|
||||||
className,
|
className={classnames('ReactTable', className, rootProps.className)}
|
||||||
rootProps.className
|
style={{
|
||||||
)}
|
...style,
|
||||||
style={{
|
...rootProps.style
|
||||||
...style,
|
}}
|
||||||
...rootProps.style
|
{...rootProps.rest}
|
||||||
}}
|
|
||||||
{...rootProps.rest}
|
|
||||||
>
|
|
||||||
<TableComponent
|
|
||||||
className={classnames(
|
|
||||||
tableProps.className,
|
|
||||||
currentlyResizing ? 'rt-resizing' : ''
|
|
||||||
)}
|
|
||||||
style={tableProps.style}
|
|
||||||
{...tableProps.rest}
|
|
||||||
>
|
>
|
||||||
{hasHeaderGroups ? makeHeaderGroups() : null}
|
{showPagination && showPaginationTop
|
||||||
{makeHeaders()}
|
? <div className="pagination-top">
|
||||||
{hasFilters ? makeFilters() : null}
|
{pagination}
|
||||||
<TbodyComponent
|
</div>
|
||||||
className={classnames(tBodyProps.className)}
|
: null}
|
||||||
style={{
|
<TableComponent
|
||||||
...tBodyProps.style,
|
className={classnames(
|
||||||
minWidth: `${rowMinWidth}px`
|
tableProps.className,
|
||||||
}}
|
currentlyResizing ? 'rt-resizing' : ''
|
||||||
{...tBodyProps.rest}
|
)}
|
||||||
|
style={tableProps.style}
|
||||||
|
{...tableProps.rest}
|
||||||
>
|
>
|
||||||
{pageRows.map((d, i) => makePageRow(d, i))}
|
{hasHeaderGroups ? makeHeaderGroups() : null}
|
||||||
{padRows.map(makePadRow)}
|
{makeHeaders()}
|
||||||
</TbodyComponent>
|
{hasFilters ? makeFilters() : null}
|
||||||
{hasColumnFooter ? makeColumnFooters() : null}
|
<TbodyComponent
|
||||||
</TableComponent>
|
className={classnames(tBodyProps.className)}
|
||||||
{showPagination ? (
|
style={{
|
||||||
<PaginationComponent
|
...tBodyProps.style,
|
||||||
{...resolvedState}
|
minWidth: `${rowMinWidth}px`
|
||||||
pages={pages}
|
}}
|
||||||
canPrevious={canPrevious}
|
{...tBodyProps.rest}
|
||||||
canNext={canNext}
|
>
|
||||||
onPageChange={this.onPageChange}
|
{pageRows.map((d, i) => makePageRow(d, i))}
|
||||||
onPageSizeChange={this.onPageSizeChange}
|
{padRows.map(makePadRow)}
|
||||||
className={paginationProps.className}
|
</TbodyComponent>
|
||||||
style={paginationProps.style}
|
{hasColumnFooter ? makeColumnFooters() : null}
|
||||||
{...paginationProps.rest}
|
</TableComponent>
|
||||||
|
{showPagination && showPaginationBottom
|
||||||
|
? <div className="pagination-bottom">
|
||||||
|
{pagination}
|
||||||
|
</div>
|
||||||
|
: null}
|
||||||
|
{!pageRows.length &&
|
||||||
|
<NoDataComponent {...noDataProps}>
|
||||||
|
{_.normalizeComponent(noDataText)}
|
||||||
|
</NoDataComponent>}
|
||||||
|
<LoadingComponent
|
||||||
|
loading={loading}
|
||||||
|
loadingText={loadingText}
|
||||||
|
{...loadingProps}
|
||||||
/>
|
/>
|
||||||
) : null}
|
</div>
|
||||||
{!pageRows.length && (
|
)
|
||||||
<NoDataComponent
|
}
|
||||||
{...noDataProps}
|
|
||||||
>
|
|
||||||
{_.normalizeComponent(noDataText)}
|
|
||||||
</NoDataComponent>
|
|
||||||
)}
|
|
||||||
<LoadingComponent
|
|
||||||
loading={loading}
|
|
||||||
loadingText={loadingText}
|
|
||||||
{...loadingProps}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
|
|
||||||
// childProps are optionally passed to a function-as-a-child
|
// childProps are optionally passed to a function-as-a-child
|
||||||
return children ? children(finalState, makeTable, this) : makeTable()
|
return children ? children(finalState, makeTable, this) : makeTable()
|
||||||
|
|||||||
+12
-1
@@ -4,10 +4,13 @@ $expandSize = 7px
|
|||||||
|
|
||||||
.ReactTable
|
.ReactTable
|
||||||
position:relative
|
position:relative
|
||||||
|
display: flex
|
||||||
|
flex-direction: column
|
||||||
border: 1px solid alpha(black, .1)
|
border: 1px solid alpha(black, .1)
|
||||||
*
|
*
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
.rt-table
|
.rt-table
|
||||||
|
flex: 1
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
align-items: stretch
|
align-items: stretch
|
||||||
@@ -16,7 +19,9 @@ $expandSize = 7px
|
|||||||
overflow: auto
|
overflow: auto
|
||||||
|
|
||||||
.rt-thead
|
.rt-thead
|
||||||
|
flex: 1 0 auto
|
||||||
display: flex
|
display: flex
|
||||||
|
// overflow-y: scroll
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
@@ -91,8 +96,10 @@ $expandSize = 7px
|
|||||||
margin-top: -10px
|
margin-top: -10px
|
||||||
|
|
||||||
.rt-tbody
|
.rt-tbody
|
||||||
|
flex: 99999 1 auto
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
|
overflow: auto
|
||||||
// z-index:0
|
// z-index:0
|
||||||
.rt-tr-group
|
.rt-tr-group
|
||||||
border-bottom: solid 1px alpha(black, .05)
|
border-bottom: solid 1px alpha(black, .05)
|
||||||
@@ -105,10 +112,12 @@ $expandSize = 7px
|
|||||||
.rt-expandable
|
.rt-expandable
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
.rt-tr-group
|
.rt-tr-group
|
||||||
|
flex: 1 0 auto
|
||||||
display: flex
|
display: flex
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
align-items: stretch
|
align-items: stretch
|
||||||
.rt-tr
|
.rt-tr
|
||||||
|
flex: 1 0 auto
|
||||||
display: inline-flex
|
display: inline-flex
|
||||||
.rt-th
|
.rt-th
|
||||||
.rt-td
|
.rt-td
|
||||||
@@ -191,7 +200,7 @@ $expandSize = 7px
|
|||||||
appearance:none
|
appearance:none
|
||||||
display:block
|
display:block
|
||||||
width:100%
|
width:100%
|
||||||
height: 100%
|
height:100%
|
||||||
border: 0
|
border: 0
|
||||||
border-radius: 3px
|
border-radius: 3px
|
||||||
padding: 6px
|
padding: 6px
|
||||||
@@ -296,6 +305,8 @@ $expandSize = 7px
|
|||||||
input:not([type="checkbox"]):not([type="radio"])
|
input:not([type="checkbox"]):not([type="radio"])
|
||||||
select
|
select
|
||||||
appearance: none
|
appearance: none
|
||||||
|
&::-ms-expand
|
||||||
|
display: none
|
||||||
|
|
||||||
.select-wrap
|
.select-wrap
|
||||||
position:relative
|
position:relative
|
||||||
|
|||||||
+104
-87
@@ -1,101 +1,118 @@
|
|||||||
export default Base => class extends Base {
|
export default Base =>
|
||||||
|
class extends Base {
|
||||||
componentWillMount () {
|
componentWillMount () {
|
||||||
this.setStateWithData(this.getDataModel(this.getResolvedState()))
|
this.setStateWithData(this.getDataModel(this.getResolvedState()))
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
this.fireFetchData()
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps, nextState) {
|
|
||||||
const oldState = this.getResolvedState()
|
|
||||||
const newState = this.getResolvedState(nextProps, nextState)
|
|
||||||
|
|
||||||
// Do a deep compare of new and old `defaultOption` and
|
|
||||||
// if they are different reset `option = defaultOption`
|
|
||||||
const defaultableOptions = ['sorted', 'filtered', 'resized', 'expanded']
|
|
||||||
defaultableOptions.forEach(x => {
|
|
||||||
const defaultName = `default${x.charAt(0).toUpperCase() + x.slice(1)}`
|
|
||||||
if (JSON.stringify(oldState[defaultName]) !== JSON.stringify(newState[defaultName])) {
|
|
||||||
newState[x] = newState[defaultName]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// If they change these table options, we need to reset defaults
|
|
||||||
// or else we could get into a state where the user has changed the UI
|
|
||||||
// and then disabled the ability to change it back.
|
|
||||||
// e.g. If `filterable` has changed, set `filtered = defaultFiltered`
|
|
||||||
const resettableOptions = ['sortable', 'filterable', 'resizable']
|
|
||||||
resettableOptions.forEach(x => {
|
|
||||||
if (oldState[x] !== newState[x]) {
|
|
||||||
const baseName = x.replace('able', '')
|
|
||||||
const optionName = `${baseName}ed`
|
|
||||||
const defaultName = `default${optionName.charAt(0).toUpperCase() + optionName.slice(1)}`
|
|
||||||
newState[optionName] = newState[defaultName]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Props that trigger a data update
|
|
||||||
if (
|
|
||||||
oldState.data !== newState.data ||
|
|
||||||
oldState.columns !== newState.columns ||
|
|
||||||
oldState.pivotBy !== newState.pivotBy ||
|
|
||||||
oldState.sorted !== newState.sorted ||
|
|
||||||
oldState.filtered !== newState.filtered
|
|
||||||
) {
|
|
||||||
this.setStateWithData(this.getDataModel(newState))
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
setStateWithData (newState, cb) {
|
componentDidMount () {
|
||||||
const oldState = this.getResolvedState()
|
this.fireFetchData()
|
||||||
const newResolvedState = this.getResolvedState({}, newState)
|
}
|
||||||
const {freezeWhenExpanded} = newResolvedState
|
|
||||||
|
|
||||||
// Default to unfrozen state
|
componentWillReceiveProps (nextProps, nextState) {
|
||||||
newResolvedState.frozen = false
|
const oldState = this.getResolvedState()
|
||||||
|
const newState = this.getResolvedState(nextProps, nextState)
|
||||||
|
|
||||||
// If freezeWhenExpanded is set, check for frozen conditions
|
// Do a deep compare of new and old `defaultOption` and
|
||||||
if (freezeWhenExpanded) {
|
// if they are different reset `option = defaultOption`
|
||||||
// if any rows are expanded, freeze the existing data and sorting
|
const defaultableOptions = ['sorted', 'filtered', 'resized', 'expanded']
|
||||||
const keys = Object.keys(newResolvedState.expanded)
|
defaultableOptions.forEach(x => {
|
||||||
for (var i = 0; i < keys.length; i++) {
|
const defaultName = `default${x.charAt(0).toUpperCase() + x.slice(1)}`
|
||||||
if (newResolvedState.expanded[keys[i]]) {
|
if (
|
||||||
newResolvedState.frozen = true
|
JSON.stringify(oldState[defaultName]) !==
|
||||||
break
|
JSON.stringify(newState[defaultName])
|
||||||
|
) {
|
||||||
|
newState[x] = newState[defaultName]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// If they change these table options, we need to reset defaults
|
||||||
|
// or else we could get into a state where the user has changed the UI
|
||||||
|
// and then disabled the ability to change it back.
|
||||||
|
// e.g. If `filterable` has changed, set `filtered = defaultFiltered`
|
||||||
|
const resettableOptions = ['sortable', 'filterable', 'resizable']
|
||||||
|
resettableOptions.forEach(x => {
|
||||||
|
if (oldState[x] !== newState[x]) {
|
||||||
|
const baseName = x.replace('able', '')
|
||||||
|
const optionName = `${baseName}ed`
|
||||||
|
const defaultName = `default${optionName.charAt(0).toUpperCase() +
|
||||||
|
optionName.slice(1)}`
|
||||||
|
newState[optionName] = newState[defaultName]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Props that trigger a data update
|
||||||
|
if (
|
||||||
|
oldState.data !== newState.data ||
|
||||||
|
oldState.columns !== newState.columns ||
|
||||||
|
oldState.pivotBy !== newState.pivotBy ||
|
||||||
|
oldState.sorted !== newState.sorted ||
|
||||||
|
oldState.filtered !== newState.filtered
|
||||||
|
) {
|
||||||
|
this.setStateWithData(this.getDataModel(newState))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setStateWithData (newState, cb) {
|
||||||
|
const oldState = this.getResolvedState()
|
||||||
|
const newResolvedState = this.getResolvedState({}, newState)
|
||||||
|
const { freezeWhenExpanded } = newResolvedState
|
||||||
|
|
||||||
|
// Default to unfrozen state
|
||||||
|
newResolvedState.frozen = false
|
||||||
|
|
||||||
|
// If freezeWhenExpanded is set, check for frozen conditions
|
||||||
|
if (freezeWhenExpanded) {
|
||||||
|
// if any rows are expanded, freeze the existing data and sorting
|
||||||
|
const keys = Object.keys(newResolvedState.expanded)
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
if (newResolvedState.expanded[keys[i]]) {
|
||||||
|
newResolvedState.frozen = true
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If the data isn't frozen and either the data or
|
// If the data isn't frozen and either the data or
|
||||||
// sorting model has changed, update the data
|
// sorting model has changed, update the data
|
||||||
if (
|
|
||||||
(oldState.frozen && !newResolvedState.frozen) ||
|
|
||||||
oldState.sorted !== newResolvedState.sorted ||
|
|
||||||
oldState.filtered !== newResolvedState.filtered ||
|
|
||||||
oldState.showFilters !== newResolvedState.showFilters ||
|
|
||||||
(!newResolvedState.frozen && oldState.resolvedData !== newResolvedState.resolvedData)
|
|
||||||
) {
|
|
||||||
// Handle collapseOnsortedChange & collapseOnDataChange
|
|
||||||
if (
|
if (
|
||||||
(oldState.sorted !== newResolvedState.sorted && this.props.collapseOnSortingChange) ||
|
(oldState.frozen && !newResolvedState.frozen) ||
|
||||||
(oldState.filtered !== newResolvedState.filtered) ||
|
oldState.sorted !== newResolvedState.sorted ||
|
||||||
(oldState.showFilters !== newResolvedState.showFilters) ||
|
oldState.filtered !== newResolvedState.filtered ||
|
||||||
(!newResolvedState.frozen && oldState.resolvedData !== newResolvedState.resolvedData && this.props.collapseOnDataChange)
|
oldState.showFilters !== newResolvedState.showFilters ||
|
||||||
|
(!newResolvedState.frozen &&
|
||||||
|
oldState.resolvedData !== newResolvedState.resolvedData)
|
||||||
) {
|
) {
|
||||||
newResolvedState.expanded = {}
|
// Handle collapseOnsortedChange & collapseOnDataChange
|
||||||
|
if (
|
||||||
|
(oldState.sorted !== newResolvedState.sorted &&
|
||||||
|
this.props.collapseOnSortingChange) ||
|
||||||
|
oldState.filtered !== newResolvedState.filtered ||
|
||||||
|
oldState.showFilters !== newResolvedState.showFilters ||
|
||||||
|
(!newResolvedState.frozen &&
|
||||||
|
oldState.resolvedData !== newResolvedState.resolvedData &&
|
||||||
|
this.props.collapseOnDataChange)
|
||||||
|
) {
|
||||||
|
newResolvedState.expanded = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(newResolvedState, this.getSortedData(newResolvedState))
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(newResolvedState, this.getSortedData(newResolvedState))
|
// Calculate pageSize all the time
|
||||||
}
|
if (newResolvedState.sortedData) {
|
||||||
|
newResolvedState.pages = newResolvedState.manual
|
||||||
|
? newResolvedState.pages
|
||||||
|
: Math.ceil(
|
||||||
|
newResolvedState.sortedData.length / newResolvedState.pageSize
|
||||||
|
)
|
||||||
|
newResolvedState.page = Math.max(
|
||||||
|
newResolvedState.page >= newResolvedState.pages
|
||||||
|
? newResolvedState.pages - 1
|
||||||
|
: newResolvedState.page,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate pageSize all the time
|
return this.setState(newResolvedState, cb)
|
||||||
if (newResolvedState.sortedData) {
|
|
||||||
newResolvedState.pages = newResolvedState.manual ? newResolvedState.pages : Math.ceil(newResolvedState.sortedData.length / newResolvedState.pageSize)
|
|
||||||
newResolvedState.page = Math.max(newResolvedState.page >= newResolvedState.pages ? newResolvedState.pages - 1 : newResolvedState.page, 0)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.setState(newResolvedState, cb)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
+651
-620
File diff suppressed because it is too large
Load Diff
+36
-39
@@ -3,9 +3,8 @@ import classnames from 'classnames'
|
|||||||
//
|
//
|
||||||
// import _ from './utils'
|
// import _ from './utils'
|
||||||
|
|
||||||
const defaultButton = (props) => (
|
const defaultButton = props =>
|
||||||
<button type='button' {...props} className='-btn'>{props.children}</button>
|
<button type='button' {...props} className='-btn'>{props.children}</button>
|
||||||
)
|
|
||||||
|
|
||||||
export default class ReactTablePagination extends Component {
|
export default class ReactTablePagination extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -16,12 +15,12 @@ export default class ReactTablePagination extends Component {
|
|||||||
this.applyPage = this.applyPage.bind(this)
|
this.applyPage = this.applyPage.bind(this)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
page: props.page
|
page: props.page,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
this.setState({page: nextProps.page})
|
this.setState({ page: nextProps.page })
|
||||||
}
|
}
|
||||||
|
|
||||||
getSafePage (page) {
|
getSafePage (page) {
|
||||||
@@ -33,7 +32,7 @@ export default class ReactTablePagination extends Component {
|
|||||||
|
|
||||||
changePage (page) {
|
changePage (page) {
|
||||||
page = this.getSafePage(page)
|
page = this.getSafePage(page)
|
||||||
this.setState({page})
|
this.setState({ page })
|
||||||
if (this.props.page !== page) {
|
if (this.props.page !== page) {
|
||||||
this.props.onPageChange(page)
|
this.props.onPageChange(page)
|
||||||
}
|
}
|
||||||
@@ -60,7 +59,7 @@ export default class ReactTablePagination extends Component {
|
|||||||
onPageSizeChange,
|
onPageSizeChange,
|
||||||
className,
|
className,
|
||||||
PreviousComponent = defaultButton,
|
PreviousComponent = defaultButton,
|
||||||
NextComponent = defaultButton
|
NextComponent = defaultButton,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -70,7 +69,7 @@ export default class ReactTablePagination extends Component {
|
|||||||
>
|
>
|
||||||
<div className='-previous'>
|
<div className='-previous'>
|
||||||
<PreviousComponent
|
<PreviousComponent
|
||||||
onClick={(e) => {
|
onClick={e => {
|
||||||
if (!canPrevious) return
|
if (!canPrevious) return
|
||||||
this.changePage(page - 1)
|
this.changePage(page - 1)
|
||||||
}}
|
}}
|
||||||
@@ -81,53 +80,51 @@ export default class ReactTablePagination extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<div className='-center'>
|
<div className='-center'>
|
||||||
<span className='-pageInfo'>
|
<span className='-pageInfo'>
|
||||||
{this.props.pageText} {showPageJump ? (
|
{this.props.pageText}{' '}
|
||||||
<div className='-pageJump'>
|
{showPageJump
|
||||||
<input
|
? <div className='-pageJump'>
|
||||||
type={this.state.page === '' ? 'text' : 'number'}
|
<input
|
||||||
onChange={e => {
|
type={this.state.page === '' ? 'text' : 'number'}
|
||||||
const val = e.target.value
|
onChange={e => {
|
||||||
const page = val - 1
|
const val = e.target.value
|
||||||
if (val === '') {
|
const page = val - 1
|
||||||
return this.setState({page: val})
|
if (val === '') {
|
||||||
}
|
return this.setState({ page: val })
|
||||||
this.setState({page: this.getSafePage(page)})
|
}
|
||||||
}}
|
this.setState({ page: this.getSafePage(page) })
|
||||||
value={this.state.page === '' ? '' : this.state.page + 1}
|
}}
|
||||||
onBlur={this.applyPage}
|
value={this.state.page === '' ? '' : this.state.page + 1}
|
||||||
onKeyPress={e => {
|
onBlur={this.applyPage}
|
||||||
if (e.which === 13 || e.keyCode === 13) {
|
onKeyPress={e => {
|
||||||
this.applyPage()
|
if (e.which === 13 || e.keyCode === 13) {
|
||||||
}
|
this.applyPage()
|
||||||
}}
|
}
|
||||||
/>
|
}}
|
||||||
</div>
|
/>
|
||||||
) : (
|
</div>
|
||||||
<span className='-currentPage'>{page + 1}</span>
|
: <span className='-currentPage'>{page + 1}</span>}{' '}
|
||||||
)} {this.props.ofText} <span className='-totalPages'>{pages || 1}</span>
|
{this.props.ofText}{' '}
|
||||||
|
<span className='-totalPages'>{pages || 1}</span>
|
||||||
</span>
|
</span>
|
||||||
{showPageSizeOptions && (
|
{showPageSizeOptions &&
|
||||||
<span className='select-wrap -pageSizeOptions'>
|
<span className='select-wrap -pageSizeOptions'>
|
||||||
<select
|
<select
|
||||||
onChange={(e) => onPageSizeChange(Number(e.target.value))}
|
onChange={e => onPageSizeChange(Number(e.target.value))}
|
||||||
value={pageSize}
|
value={pageSize}
|
||||||
>
|
>
|
||||||
{pageSizeOptions.map((option, i) => {
|
{pageSizeOptions.map((option, i) => {
|
||||||
return (
|
return (
|
||||||
<option
|
<option key={i} value={option}>
|
||||||
key={i}
|
|
||||||
value={option}>
|
|
||||||
{option} {this.props.rowsText}
|
{option} {this.props.rowsText}
|
||||||
</option>
|
</option>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className='-next'>
|
<div className='-next'>
|
||||||
<NextComponent
|
<NextComponent
|
||||||
onClick={(e) => {
|
onClick={e => {
|
||||||
if (!canNext) return
|
if (!canNext) return
|
||||||
this.changePage(page + 1)
|
this.changePage(page + 1)
|
||||||
}}
|
}}
|
||||||
|
|||||||
+27
-27
@@ -18,7 +18,7 @@ export default {
|
|||||||
splitProps,
|
splitProps,
|
||||||
compactObject,
|
compactObject,
|
||||||
isSortingDesc,
|
isSortingDesc,
|
||||||
normalizeComponent
|
normalizeComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
function get (obj, path, def) {
|
function get (obj, path, def) {
|
||||||
@@ -94,12 +94,14 @@ function remove (a, b) {
|
|||||||
|
|
||||||
function clone (a) {
|
function clone (a) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(JSON.stringify(a, (key, value) => {
|
return JSON.parse(
|
||||||
if (typeof value === 'function') {
|
JSON.stringify(a, (key, value) => {
|
||||||
return value.toString()
|
if (typeof value === 'function') {
|
||||||
}
|
return value.toString()
|
||||||
return value
|
}
|
||||||
}))
|
return value
|
||||||
|
})
|
||||||
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
@@ -120,14 +122,10 @@ function sum (arr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeTemplateComponent (compClass) {
|
function makeTemplateComponent (compClass) {
|
||||||
return ({children, className, ...rest}) => (
|
return ({ children, className, ...rest }) =>
|
||||||
<div
|
<div className={classnames(compClass, className)} {...rest}>
|
||||||
className={classnames(compClass, className)}
|
|
||||||
{...rest}
|
|
||||||
>
|
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupBy (xs, key) {
|
function groupBy (xs, key) {
|
||||||
@@ -149,10 +147,10 @@ function isArray (a) {
|
|||||||
|
|
||||||
function makePathArray (obj) {
|
function makePathArray (obj) {
|
||||||
return flattenDeep(obj)
|
return flattenDeep(obj)
|
||||||
.join('.')
|
.join('.')
|
||||||
.replace('[', '.')
|
.replace('[', '.')
|
||||||
.replace(']', '')
|
.replace(']', '')
|
||||||
.split('.')
|
.split('.')
|
||||||
}
|
}
|
||||||
|
|
||||||
function flattenDeep (arr, newArr = []) {
|
function flattenDeep (arr, newArr = []) {
|
||||||
@@ -166,18 +164,22 @@ function flattenDeep (arr, newArr = []) {
|
|||||||
return newArr
|
return newArr
|
||||||
}
|
}
|
||||||
|
|
||||||
function splitProps ({className, style, ...rest}) {
|
function splitProps ({ className, style, ...rest }) {
|
||||||
return {
|
return {
|
||||||
className,
|
className,
|
||||||
style,
|
style,
|
||||||
rest
|
rest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function compactObject (obj) {
|
function compactObject (obj) {
|
||||||
const newObj = {}
|
const newObj = {}
|
||||||
for (var key in obj) {
|
for (var key in obj) {
|
||||||
if (obj.hasOwnProperty(key) && obj[key] !== undefined && typeof obj[key] !== 'undefined') {
|
if (
|
||||||
|
obj.hasOwnProperty(key) &&
|
||||||
|
obj[key] !== undefined &&
|
||||||
|
typeof obj[key] !== 'undefined'
|
||||||
|
) {
|
||||||
newObj[key] = obj[key]
|
newObj[key] = obj[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,11 +191,9 @@ function isSortingDesc (d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function normalizeComponent (Comp, params = {}, fallback = Comp) {
|
function normalizeComponent (Comp, params = {}, fallback = Comp) {
|
||||||
return typeof Comp === 'function' ? (
|
return typeof Comp === 'function'
|
||||||
Object.getPrototypeOf(Comp).isReactComponent ? (
|
? Object.getPrototypeOf(Comp).isReactComponent
|
||||||
<Comp
|
? <Comp {...params} />
|
||||||
{...params}
|
: Comp(params)
|
||||||
/>
|
: fallback
|
||||||
) : Comp(params)
|
|
||||||
) : fallback
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user