Skip to content

Commit c97aeb1

Browse files
committed
Merge branch 'master' of https://github.com/bsalex/react-data-components into bsalex-master
2 parents 72fd918 + c26a59f commit c97aeb1

12 files changed

+105
-95
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: node_js
22

33
node_js:
4-
- "iojs"
5-
4+
- "4.1"

example/flux/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var React = require('react');
2+
var ReactDOM = require('react-dom');
23
var FluxTable = require('./FluxTable');
34
var WebAPIUtils = require('./WebAPIUtils');
45
var DataStore = require('./DataStore');
@@ -21,4 +22,4 @@ DataStore.init({
2122

2223
WebAPIUtils.getCsvFile('/sample_data.csv');
2324

24-
React.render(<FluxTable />, document.body);
25+
ReactDOM.render(<FluxTable />, document.getElementById('app'));

example/flux/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<link rel="stylesheet" href="https://cdn.rawgit.com/carlosrocha/react-data-components/master/css/table-twbs.css">
77
</head>
88
<body>
9+
<div id="app"></div>
910
<script src="../flux.entry.js"></script>
1011
</body>
1112
</html>

example/table/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
</head>
88
<body>
99
<script src="../table.entry.js"></script>
10+
<div id="app" />
1011
</body>
1112
</html>

example/table/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var React = require('react');
2+
var ReactDOM = require('react-dom');
23
var { DataTable } = require('react-data-components');
34
var d3 = require('d3');
45

@@ -31,5 +32,5 @@ function buildTable(data) {
3132
}
3233

3334
d3.csv('/sample_data.csv', function(error, rows) {
34-
React.render(buildTable(rows), document.body);
35+
ReactDOM.render(buildTable(rows), document.getElementById('app'));
3536
});

package.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"CHANGELOG.md",
1616
"LICENSE",
1717
"css",
18-
"lib"
18+
"lib",
19+
"src"
1920
],
2021
"repository": {
2122
"type": "git",
@@ -24,22 +25,24 @@
2425
"babel": {
2526
"stage": 0
2627
},
27-
"peerDependencies": {
28-
"react": "^0.13.0"
29-
},
3028
"devDependencies": {
3129
"babel": "^5.8.21",
3230
"babel-eslint": "^4.0.8",
3331
"babel-jest": "^5.3.0",
34-
"babel-loader": "^5.3.1",
32+
"babel-loader": "^5.3.3",
33+
"babel-plugin-transform-es2015-modules-commonjs": "^6.0.2",
34+
"babel-plugin-transform-react-constant-elements": "^6.0.2",
35+
"babel-preset-es2015": "^6.0.12",
36+
"babel-preset-react": "^6.0.2",
3537
"d3": "^3.5.6",
36-
"eslint": "^1.1.0",
37-
"eslint-plugin-react": "^3.2.2",
38-
"flux": "^2.0.3",
39-
"jest-cli": "^0.5.0",
40-
"rimraf": "^2.4.2",
41-
"webpack": "^1.11.0",
42-
"webpack-dev-server": "^1.10.1"
38+
"eslint": "^1.7.3",
39+
"eslint-plugin-react": "^3.6.3",
40+
"flux": "^2.1.1",
41+
"jest-cli": "^0.6.1",
42+
"react-addons-test-utils": "^0.14.1",
43+
"rimraf": "^2.4.3",
44+
"webpack": "^1.12.2",
45+
"webpack-dev-server": "^1.12.1"
4346
},
4447
"scripts": {
4548
"lint": "eslint src",
@@ -59,6 +62,8 @@
5962
},
6063
"dependencies": {
6164
"lodash.some": "^3.2.3",
62-
"lodash.sortby": "^3.1.5"
65+
"lodash.sortby": "^3.1.5",
66+
"react": "^0.14.1",
67+
"react-dom": "^0.14.1"
6368
}
6469
}

src/Pagination.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
import React, { PropTypes } from 'react';
1+
import React, { PropTypes, Component } from 'react';
22

33
// Used to cancel events.
44
var preventDefault = e => e.preventDefault();
55

6-
export default class Pagination {
7-
8-
static defaultProps = {
9-
showPages: 5,
10-
};
11-
12-
static propTypes = {
13-
onChangePage: PropTypes.func.isRequired,
14-
totalPages: PropTypes.number.isRequired,
15-
currentPage: PropTypes.number.isRequired,
16-
showPages: PropTypes.number,
17-
};
18-
6+
export default class Pagination extends Component {
197
shouldComponentUpdate(nextProps) {
208
var props = this.props;
219

@@ -127,3 +115,14 @@ export default class Pagination {
127115
);
128116
}
129117
}
118+
119+
Pagination.defaultProps = {
120+
showPages: 5,
121+
};
122+
123+
Pagination.propTypes = {
124+
onChangePage: PropTypes.func.isRequired,
125+
totalPages: PropTypes.number.isRequired,
126+
currentPage: PropTypes.number.isRequired,
127+
showPages: PropTypes.number,
128+
};

src/SearchField.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
var React = require('react');
1+
import React, { Component } from 'react';
22

3-
class SearchField {
3+
class SearchField extends Component {
44

5-
constructor() {
5+
constructor(...props) {
6+
super(...props);
67
this.onChange = this.onChange.bind(this);
78
}
89

src/SelectField.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
var React = require('react');
1+
import React, { Component } from 'react';
22

3-
class SelectField {
3+
class SelectField extends Component {
44

5-
constructor() {
5+
constructor(...props) {
6+
super(...props);
67
this.onChange = this.onChange.bind(this);
78
}
89

src/Table.js

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { PropTypes } from 'react';
1+
import React, { PropTypes, Component } from 'react';
2+
import ReactDOM from 'react-dom';
23

34
let simpleGet = key => data => data[key];
45
let keyGetter = keys => data => keys.map(key => data[key]);
@@ -37,66 +38,17 @@ function buildSortProps(col, sortBy, onSort) {
3738
};
3839
}
3940

40-
export default class Table {
41-
42-
static defaultProps = {
43-
buildRowOptions: () => ({}),
44-
sortBy: {},
45-
};
46-
47-
static propTypes = {
48-
49-
keys: PropTypes.oneOfType([
50-
PropTypes.arrayOf(PropTypes.string),
51-
PropTypes.string,
52-
]).isRequired,
53-
54-
columns: PropTypes.arrayOf(PropTypes.shape({
55-
title: PropTypes.string.isRequired,
56-
prop: PropTypes.oneOfType([
57-
PropTypes.string,
58-
PropTypes.number,
59-
]),
60-
render: PropTypes.func,
61-
sortable: PropTypes.bool,
62-
defaultContent: PropTypes.string,
63-
width: PropTypes.oneOfType([
64-
PropTypes.string,
65-
PropTypes.number,
66-
]),
67-
className: PropTypes.oneOfType([
68-
PropTypes.string,
69-
PropTypes.func,
70-
]),
71-
})).isRequired,
72-
73-
dataArray: PropTypes.arrayOf(PropTypes.oneOfType([
74-
PropTypes.array,
75-
PropTypes.object,
76-
])).isRequired,
77-
78-
buildRowOptions: PropTypes.func,
79-
80-
sortBy: PropTypes.shape({
81-
prop: PropTypes.oneOfType([
82-
PropTypes.string,
83-
PropTypes.number,
84-
]),
85-
order: PropTypes.oneOf([ 'ascending', 'descending' ]),
86-
}),
87-
88-
onSort: PropTypes.func,
89-
};
90-
91-
constructor() {
41+
export default class Table extends Component {
42+
constructor(props) {
43+
super(props);
9244
this._headers = [];
9345
}
9446

9547
componentDidMount() {
9648
// If no width was specified, then set the width that the browser applied
9749
// initially to avoid recalculating width between pages.
9850
this._headers.forEach(header => {
99-
let thDom = React.findDOMNode(header);
51+
let thDom = ReactDOM.findDOMNode(header);
10052
if (!thDom.style.width) {
10153
thDom.style.width = `${thDom.offsetWidth}px`;
10254
}
@@ -166,3 +118,52 @@ export default class Table {
166118
}
167119

168120
}
121+
122+
123+
Table.defaultProps = {
124+
buildRowOptions: () => ({}),
125+
sortBy: {},
126+
};
127+
128+
Table.propTypes = {
129+
keys: PropTypes.oneOfType([
130+
PropTypes.arrayOf(PropTypes.string),
131+
PropTypes.string,
132+
]).isRequired,
133+
134+
columns: PropTypes.arrayOf(PropTypes.shape({
135+
title: PropTypes.string.isRequired,
136+
prop: PropTypes.oneOfType([
137+
PropTypes.string,
138+
PropTypes.number,
139+
]),
140+
render: PropTypes.func,
141+
sortable: PropTypes.bool,
142+
defaultContent: PropTypes.string,
143+
width: PropTypes.oneOfType([
144+
PropTypes.string,
145+
PropTypes.number,
146+
]),
147+
className: PropTypes.oneOfType([
148+
PropTypes.string,
149+
PropTypes.func,
150+
]),
151+
})).isRequired,
152+
153+
dataArray: PropTypes.arrayOf(PropTypes.oneOfType([
154+
PropTypes.array,
155+
PropTypes.object,
156+
])).isRequired,
157+
158+
buildRowOptions: PropTypes.func,
159+
160+
sortBy: PropTypes.shape({
161+
prop: PropTypes.oneOfType([
162+
PropTypes.string,
163+
PropTypes.number,
164+
]),
165+
order: PropTypes.oneOf([ 'ascending', 'descending' ]),
166+
}),
167+
168+
onSort: PropTypes.func,
169+
};

src/__tests__/Pagination-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ describe('Pagination', function() {
88
var Pagination;
99

1010
beforeEach(function() {
11-
React = require('react/addons');
12-
TestUtils = React.addons.TestUtils;
11+
React = require('react');
12+
TestUtils = require('react-addons-test-utils');
1313
Pagination = require('../Pagination');
1414
onChangePage = jest.genMockFunction();
1515
});

src/__tests__/Table-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ describe('Table', function() {
77
var Table;
88

99
beforeEach(function() {
10-
React = require('react/addons');
11-
TestUtils = React.addons.TestUtils;
10+
React = require('react');
11+
TestUtils = require('react-addons-test-utils');
1212
Table = require('../Table');
1313
});
1414

0 commit comments

Comments
 (0)