diff --git a/.gitignore b/.gitignore index 826f87a..2592bf8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ node_modules +bower_components docs/build -standalone/react-grid.min.js -standalone/react-grid.js +**/build +dist +build +examples/build diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..1df151f --- /dev/null +++ b/.jshintrc @@ -0,0 +1,22 @@ +{ + "node": true, + + "boss": true, + "curly": true, + "devel": true, + "eqnull": true, + "expr": true, + "funcscope": true, + "globalstrict": true, + "laxcomma": true, + "laxbreak": true, + "loopfunc": true, + "newcap": false, + "noempty": true, + "nonstandard": true, + "onecase": true, + "regexdash": true, + "trailing": true, + "undef": true, + "unused": "vars" +} diff --git a/README.md b/README.md index cf267b5..3a59827 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,38 @@ # React Grid -Data grid for [React][]. +Data grid for [React](http://facebook.github.io/react) + + +## Getting started +0. you'll need node, and an editor. Till visual studio does JSX, we think Atom.io is the best, so if you dont already, grab them: + + choco install atom + choco install nodejs.install *if typing npm gives you an error* + git clone https://github.com/prometheusresearch/react-grid *in the root directory you want your files in* + cd .\react-grid + +1. You'll also need Gulp which will perform build tasks such as jsx compilation (specified in gulpfile.js) - Go get it: + + npm install -g gulp + npm install --save-dev gulp + +2. Install Project Dependencies from package.json file + + npm install + +3. Run gulp. It compiles your jsx, jshint, packs your scripts up, and fires up a local webserver and opens the start page + + gulp + +Have a look in the gulpfile for other commands or add your own ## Credits -React Grid is free software created by [Prometheus Research][] and is released -under the MIT. +React Grid is from [Prometheus Research](http://prometheusresearch.github.io/react-grid) and there are some [good examples](http://prometheusresearch.github.io/react-grid/examples/locked-columns.html) +Contributions from [adazzle](https://www.adazzle.com) +It is released under the [MIT](LICENCE). + +For more details, see the [React docs](http://facebook.github.io/react/), especially [thinking in react](http://facebook.github.io/react/docs/thinking-in-react.html) -[React]: http://facebook.github.io/react/ -[Prometheus Research, LLC]: http://prometheusresearch.com +## Work in progress +This is still a work in progress but feel free to comment, add [an issue](https://github.com/prometheusresearch/react-grid/issues) or submit a [pull request](https://github.com/prometheusresearch/react-grid/pulls) diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..9ee137a --- /dev/null +++ b/bower.json @@ -0,0 +1,27 @@ +{ + "name": "react-grid", + "version": "0.0.0", + "homepage": "https://github.com/prometheusresearch/react-grid", + "authors": [ + "Prometheus Research https://github.com/prometheusresearch", + "Adazzle https://github.com/adazzle" + ], + "moduleType": [], + "license": "MIT", + "private": true, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "directory": "ext", + "dependencies": { + "jasmine": "~2.0.1", + "underscore": "~1.6.0", + "requirejs": "~2.1.14", + "jquery": "~2.1.1" + }, + "devDependencies": {} +} diff --git a/docs/contents/styles/sortable.svg b/docs/contents/styles/sortable.svg index a540079..0bf1eb5 100644 --- a/docs/contents/styles/sortable.svg +++ b/docs/contents/styles/sortable.svg @@ -1,10 +1,10 @@ - - - - - - + + + + + + diff --git a/examples/example1.html b/examples/example1.html new file mode 100644 index 0000000..9eeeae8 --- /dev/null +++ b/examples/example1.html @@ -0,0 +1,11 @@ + +
+react grid + + + + + + + + diff --git a/examples/excelGrid.html b/examples/excelGrid.html new file mode 100644 index 0000000..de71ac1 --- /dev/null +++ b/examples/excelGrid.html @@ -0,0 +1,17 @@ + + + + + +Grid with keyboard navigation
+ + + + + + diff --git a/examples/jsx/example1.jsx b/examples/jsx/example1.jsx new file mode 100644 index 0000000..1254892 --- /dev/null +++ b/examples/jsx/example1.jsx @@ -0,0 +1,49 @@ +/** + * @jsx React.DOM + */ +(function() { + +var React = require('react'); +var ReactGrid = require('../../lib/Grid.js'); + +'use strict'; + +function rows(start, end) { + var rows = []; + for (var i = start; i < end; i++) { + rows.push([i, 'Name ' + i, 'Surname ' + i]); + } + return rows; +} + +var columns = [ + { + name: '№', + width: '10%', + key: 0, + locked:true + }, + { + name: 'Name', + width: '40%', + resizeable: true, + key: 1 + }, + { + name: 'Surname', + width: '50%', + resizeable: true, + key: 2 + } +]; + + +React.renderComponent( +Examples are all located in the examples folder
+To add a new example, just add your jsx file (under the jsx folder), the html file, a link to the built jsx (under build/js/examples/your-file.jsx) and run gulp
+ + diff --git a/lib/Canvas.js b/lib/Canvas.js index f5b3d9f..f4156cb 100644 --- a/lib/Canvas.js +++ b/lib/Canvas.js @@ -18,24 +18,27 @@ */ "use strict"; + +/* jshint esnext: true */ + var React = require('react/addons'); var shallowEqual = require('./utils').shallowEqual; -var cx = React.addons.classSet; var cloneWithProps = React.addons.cloneWithProps; -var ScrollShim = require('./ScrollShim'); var Row = require('./Row'); var Canvas = React.createClass({ - mixins: [ScrollShim], propTypes: { header: React.PropTypes.component, cellRenderer: React.PropTypes.component, rowRenderer: React.PropTypes.component, rowHeight: React.PropTypes.number.isRequired, + height: React.PropTypes.number.isRequired, displayStart: React.PropTypes.number.isRequired, displayEnd: React.PropTypes.number.isRequired, length: React.PropTypes.number.isRequired, + style: React.PropTypes.object.isRequired, + SelectedCells: React.PropTypes.array.isRequired, rows: React.PropTypes.oneOfType([ React.PropTypes.func.isRequired, React.PropTypes.array.isRequired @@ -54,9 +57,12 @@ var Canvas = React.createClass({ key: displayStart + idx, idx: displayStart + idx, row: row, + isSelected: this.props.SelectedCells && this.props.SelectedCells[(displayStart + idx)] && this.props.SelectedCells[(displayStart + idx)].length, + SelectedCells: this.props.SelectedCells ? this.props.SelectedCells[(displayStart + idx)] : [], height: rowHeight, columns: this.props.columns, - cellRenderer: this.props.cellRenderer + cellRenderer: this.props.cellRenderer, + onRowClick: this.props.onRowClick })); if (displayStart > 0) { @@ -70,7 +76,7 @@ var Canvas = React.createClass({ return this.transferPropsTo(