Skip to content

Commit 15d4df5

Browse files
committed
initial commit
0 parents  commit 15d4df5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+30638
-0
lines changed

Diff for: .babelrc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": "commonjs",
7+
},
8+
],
9+
"@babel/preset-react",
10+
],
11+
"plugins": [
12+
"@babel/plugin-proposal-class-properties",
13+
"@babel/plugin-proposal-object-rest-spread",
14+
],
15+
"env": {
16+
"es": {
17+
"presets": [
18+
[
19+
"@babel/preset-env",
20+
{
21+
"modules": false,
22+
"loose": true,
23+
},
24+
],
25+
],
26+
},
27+
},
28+
}

Diff for: .eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lib/
2+
es/
3+
website/
4+
node_modules/
5+
package-lock.json
6+
yarn.lock

Diff for: .eslintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["react-app", "plugin:prettier/recommended", "prettier"],
3+
"plugins": ["prettier"]
4+
}

Diff for: .gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Ignore annoying DS files
2+
.DS_Store
3+
*.DS_Store
4+
**.DS_Store
5+
6+
# npm
7+
node_modules
8+
npm-debug.log
9+
npm-debug.log.*
10+
11+
# yarn
12+
yarn-error.log
13+
yarn-error.log.*
14+
15+
styles.css
16+
es/
17+
lib/
18+
coverage/

Diff for: .npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

Diff for: .prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib/
2+
es/

Diff for: .prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"printWidth": 120
6+
}

Diff for: CONTRIBUTING.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Contributing
2+
3+
Contributions in any form are welcome. You can contribute by reporting issues, submitting pull requests, reviewing pull requests, participating in discussions on issues and pull requests and more.
4+
5+
## Reporting issues
6+
7+
Issues can be questions, feature requests, enhancements, optimizations and more. Please use **Issues** to track them.
8+
9+
When filing a bug, it would be helpful to provide a reproducible demonstration of the bug.
10+
11+
## Submitting pull requests
12+
13+
When ready to contribute, fork this repository and submit a pull request that references the issue it resolves. Be sure to include a clear and detailed description of the changes you've made so that we can verify them and eventually merge.
14+
15+
## Maintainers
16+
17+
Maintainers are responsible for responding to pull requests and issues, as well as guiding the direction of the project.
18+
19+
If you've established yourself as an impactful contributor to the project, and are willing take on the extra work, we'd love to have your help maintaining it! Email the current maintainers for details.

Diff for: LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Autodesk, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# react-base-table
2+
3+
BaseTable is a react table component to display large data set with high performance and flexibility
4+
5+
## Install
6+
7+
```bash
8+
# npm
9+
npm install react-base-table --save
10+
11+
# yarn
12+
yarn add react-base-table
13+
```
14+
15+
## Usage
16+
17+
```js
18+
import BaseTable, { Column } from 'react-base-table'
19+
import 'react-base-table/styles.css'
20+
21+
...
22+
<BaseTable data={data} width={600} height={400}>
23+
<Column key="col0" dataKey="col0" width={100} />
24+
<Column key="col1" dataKey="col1" width={100} />
25+
...
26+
</BaseTable>
27+
...
28+
```
29+
30+
Learn more at the [website](https://autodesk.github.io/react-base-table/)
31+
32+
**`width` and `height` are required to display the table properly**
33+
34+
In the [examples](https://autodesk.github.io/react-base-table/examples)
35+
we are using a wrapper `const Table = props => <BaseTable width={720} height={400} {...props} />` to do that
36+
37+
You can use the [`AutoResizer`](https://autodesk.github.io/react-base-table/api/autoresizer) to make the table fill the container, take the [playground](https://autodesk.github.io/react-base-table/playground) for example
38+
39+
## Contributing
40+
41+
Please check [guidelines](CONTRIBUTING.md) for more details.

Diff for: package.json

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"name": "react-base-table",
3+
"version": "0.1.0",
4+
"description": "a react table component to display large data set with high performance and flexibility",
5+
"main": "lib/index.js",
6+
"module": "es/index.js",
7+
"files": [
8+
"lib/",
9+
"es/",
10+
"styles.css"
11+
],
12+
"author": "Neo Nie <[email protected]>",
13+
"license": "MIT",
14+
"repository": {
15+
"type": "git",
16+
"url": "https://github.com/Autodesk/react-base-table.git"
17+
},
18+
"scripts": {
19+
"lint": "eslint ./src/**/*.js",
20+
"clean": "rimraf lib es styles.css",
21+
"build:js": "cross-env NODE_ENV=production babel src -d lib --ignore 'src/**/*.spec.js' --copy-files --source-maps",
22+
"build:es": "cross-env BABEL_ENV=es NODE_ENV=production babel src -d es --ignore 'src/**/*.spec.js' --copy-files --source-maps",
23+
"build:css": "node-sass src/_BaseTable.scss ./styles.css --output-style expanded",
24+
"build": "npm run build:js && npm run build:es && npm run build:css",
25+
"format": "prettier --write 'src/**/*.{js,scss}'",
26+
"prebuild": "npm run clean",
27+
"precommit": "lint-staged",
28+
"prepush": "npm run test",
29+
"test": "jest"
30+
},
31+
"lint-staged": {
32+
"packages/**/*.scss": [
33+
"prettier --write",
34+
"git add"
35+
],
36+
"packages/**/*.js": [
37+
"prettier --write",
38+
"eslint -c .eslintrc",
39+
"git add"
40+
]
41+
},
42+
"dependencies": {
43+
"classnames": "^2.2.5",
44+
"lodash": "^4.17.5",
45+
"memoize-one": "^5.0.0",
46+
"prop-types": "^15.6.0",
47+
"react-draggable": "^3.0.5",
48+
"react-virtualized": "^9.18.5"
49+
},
50+
"peerDependencies": {
51+
"react": "^16.0.0",
52+
"react-dom": "^16.0.0"
53+
},
54+
"devDependencies": {
55+
"@babel/cli": "^7.0.0",
56+
"@babel/core": "^7.0.0",
57+
"@babel/plugin-proposal-class-properties": "^7.0.0",
58+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
59+
"@babel/preset-env": "^7.0.0",
60+
"@babel/preset-react": "^7.0.0",
61+
"babel-core": "^7.0.0-bridge.0",
62+
"babel-eslint": "^9.0.0",
63+
"babel-jest": "^23.4.2",
64+
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
65+
"cross-env": "^5.2.0",
66+
"eslint": "^5.6.0",
67+
"eslint-config-prettier": "^3.0.1",
68+
"eslint-config-react-app": "^3.0.8",
69+
"eslint-plugin-flowtype": "^3.4.2",
70+
"eslint-plugin-import": "^2.14.0",
71+
"eslint-plugin-jsx-a11y": "^6.1.1",
72+
"eslint-plugin-prettier": "^2.6.2",
73+
"eslint-plugin-react": "^7.11.1",
74+
"husky": "^0.14.3",
75+
"jest": "^23.5.0",
76+
"lerna": "^3.2.1",
77+
"lint-staged": "^7.2.2",
78+
"node-sass": "^4.9.3",
79+
"prettier": "^1.14.2",
80+
"react": "^16.4.2",
81+
"react-dom": "^16.4.2",
82+
"react-test-renderer": "^16.4.2",
83+
"rimraf": "^2.6.2"
84+
},
85+
"jest": {
86+
"roots": [
87+
"<rootDir>/src"
88+
],
89+
"testRegex": ".*.spec\\.js$",
90+
"transform": {
91+
"^.+\\.jsx?$": "babel-jest"
92+
},
93+
"transformIgnorePatterns": [
94+
"<rootDir>/node_modules/"
95+
]
96+
}
97+
}

Diff for: src/AutoResizer.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
4+
5+
/**
6+
* Decorator component that automatically adjusts the width and height of a single child
7+
*/
8+
const AutoResizer = ({ className, width, height, children, onResize }) => {
9+
const disableWidth = typeof width === 'number';
10+
const disableHeight = typeof height === 'number';
11+
12+
if (disableWidth && disableHeight) {
13+
return (
14+
<div className={className} style={{ width, height, position: 'relative' }}>
15+
{children({ width, height })}
16+
</div>
17+
);
18+
}
19+
20+
return (
21+
<AutoSizer className={className} disableWidth={disableWidth} disableHeight={disableHeight} onResize={onResize}>
22+
{size =>
23+
children({
24+
width: disableWidth ? width : size.width,
25+
height: disableHeight ? height : size.height,
26+
})
27+
}
28+
</AutoSizer>
29+
);
30+
};
31+
32+
AutoResizer.propTypes = {
33+
/**
34+
* Class name for the component
35+
*/
36+
className: PropTypes.string,
37+
/**
38+
* the width of the component, will be the container's width if not set
39+
*/
40+
width: PropTypes.number,
41+
/**
42+
* the height of the component, will be the container's width if not set
43+
*/
44+
height: PropTypes.number,
45+
/**
46+
* A callback function to render the children component
47+
* The handler is of the shape of `({ width, height }) => node`
48+
*/
49+
children: PropTypes.func.isRequired,
50+
/**
51+
* A callback function when the size of the table container changed if the width and height are not set
52+
* The handler is of the shape of `({ width, height }) => *`
53+
*/
54+
onResize: PropTypes.func,
55+
};
56+
57+
export default AutoResizer;

0 commit comments

Comments
 (0)