From a81a8798cabe8f23e9d2a85f97ace84135c35895 Mon Sep 17 00:00:00 2001 From: Huaying Tsai Date: Mon, 16 Oct 2017 19:49:23 -0700 Subject: [PATCH 1/3] fix for react 16 --- build/reactable.js | 2 +- lib/reactable/tr.js | 2 +- src/reactable/tr.jsx | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build/reactable.js b/build/reactable.js index 6702439b..fe542bbd 100644 --- a/build/reactable.js +++ b/build/reactable.js @@ -556,7 +556,7 @@ window.ReactDOM["default"] = window.ReactDOM; // Manually transfer props var props = (0, _libFilter_props_from.filterPropsFrom)(this.props); - return _react['default'].DOM.tr(props, children); + return _react['default'].createElement('tr', props, children); } }]); diff --git a/lib/reactable/tr.js b/lib/reactable/tr.js index c91e872c..3aaeecd7 100644 --- a/lib/reactable/tr.js +++ b/lib/reactable/tr.js @@ -69,7 +69,7 @@ var Tr = (function (_React$Component) { // Manually transfer props var props = (0, _libFilter_props_from.filterPropsFrom)(this.props); - return _react2['default'].DOM.tr(props, children); + return _react2['default'].createElement('tr', props, children); } }]); diff --git a/src/reactable/tr.jsx b/src/reactable/tr.jsx index 5374f96a..483748ed 100644 --- a/src/reactable/tr.jsx +++ b/src/reactable/tr.jsx @@ -38,10 +38,9 @@ export class Tr extends React.Component { // Manually transfer props var props = filterPropsFrom(this.props); - return React.DOM.tr(props, children); + return React.createElement('tr', props, children); } }; Tr.childNode = Td; Tr.dataType = 'object'; - From aa4995be0151395c467e33e71bae272d7d820dbe Mon Sep 17 00:00:00 2001 From: huaying Date: Mon, 16 Oct 2017 20:39:45 -0700 Subject: [PATCH 2/3] update reactable --- bower.json | 2 +- build/reactable.js | 15 +++++++++++++-- lib/reactable/lib/filter_props_from.js | 4 ++++ lib/reactable/thead.js | 1 + lib/reactable/tr.js | 10 ++++++++-- package.json | 2 +- src/reactable/lib/filter_props_from.jsx | 5 ++++- src/reactable/thead.jsx | 1 + src/reactable/tr.jsx | 3 +-- 9 files changed, 34 insertions(+), 9 deletions(-) diff --git a/bower.json b/bower.json index f96b0166..c0577ca4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "reactable", - "version": "0.14.0", + "version": "0.14.1", "main": "build/reactable.js", "dependencies": { "react": "0.14" diff --git a/build/reactable.js b/build/reactable.js index fe542bbd..26ce94dc 100644 --- a/build/reactable.js +++ b/build/reactable.js @@ -17,6 +17,7 @@ window.ReactDOM["default"] = window.ReactDOM; exports.filterPropsFrom = filterPropsFrom; var internalProps = { + hideTableHeader: true, column: true, columns: true, sortable: true, @@ -37,6 +38,9 @@ window.ReactDOM["default"] = window.ReactDOM; hideFilterInput: true, noDataText: true, currentPage: true, + onPageChange: true, + previousPageLabel: true, + nextPageLabel: true, pageButtonLimit: true, childNode: true, data: true, @@ -509,6 +513,8 @@ window.ReactDOM["default"] = window.ReactDOM; var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -532,10 +538,14 @@ window.ReactDOM["default"] = window.ReactDOM; console.log(children); } - children = children.concat(this.props.columns.map((function (column, i) { + children = children.concat(this.props.columns.map((function (_ref, i) { + var _ref$props = _ref.props; + var props = _ref$props === undefined ? {} : _ref$props; + + var column = _objectWithoutProperties(_ref, ['props']); + if (this.props.data.hasOwnProperty(column.key)) { var value = this.props.data[column.key]; - var props = {}; if (typeof value !== 'undefined' && value !== null && value.__reactableMeta === true) { props = value.props; @@ -748,6 +758,7 @@ window.ReactDOM["default"] = window.ReactDOM; var columns = []; _react['default'].Children.forEach(component.props.children, function (th) { var column = {}; + if (!th) return; if (typeof th.props !== 'undefined') { column.props = (0, _libFilter_props_from.filterPropsFrom)(th.props); diff --git a/lib/reactable/lib/filter_props_from.js b/lib/reactable/lib/filter_props_from.js index d3c1f4f3..b651549f 100644 --- a/lib/reactable/lib/filter_props_from.js +++ b/lib/reactable/lib/filter_props_from.js @@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.filterPropsFrom = filterPropsFrom; var internalProps = { + hideTableHeader: true, column: true, columns: true, sortable: true, @@ -25,6 +26,9 @@ var internalProps = { hideFilterInput: true, noDataText: true, currentPage: true, + onPageChange: true, + previousPageLabel: true, + nextPageLabel: true, pageButtonLimit: true, childNode: true, data: true, diff --git a/lib/reactable/thead.js b/lib/reactable/thead.js index 3326990b..d423b940 100644 --- a/lib/reactable/thead.js +++ b/lib/reactable/thead.js @@ -120,6 +120,7 @@ var Thead = (function (_React$Component) { var columns = []; _react2['default'].Children.forEach(component.props.children, function (th) { var column = {}; + if (!th) return; if (typeof th.props !== 'undefined') { column.props = (0, _libFilter_props_from.filterPropsFrom)(th.props); diff --git a/lib/reactable/tr.js b/lib/reactable/tr.js index 3aaeecd7..a51c22ac 100644 --- a/lib/reactable/tr.js +++ b/lib/reactable/tr.js @@ -12,6 +12,8 @@ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_ag function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } @@ -45,10 +47,14 @@ var Tr = (function (_React$Component) { console.log(children); } - children = children.concat(this.props.columns.map((function (column, i) { + children = children.concat(this.props.columns.map((function (_ref, i) { + var _ref$props = _ref.props; + var props = _ref$props === undefined ? {} : _ref$props; + + var column = _objectWithoutProperties(_ref, ['props']); + if (this.props.data.hasOwnProperty(column.key)) { var value = this.props.data[column.key]; - var props = {}; if (typeof value !== 'undefined' && value !== null && value.__reactableMeta === true) { props = value.props; diff --git a/package.json b/package.json index 91677bc2..926b243b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reactable", - "version": "0.14.0", + "version": "0.14.1", "description": "Fast, flexible, simple data tables in React", "main": "./lib/reactable.js", "repository": { diff --git a/src/reactable/lib/filter_props_from.jsx b/src/reactable/lib/filter_props_from.jsx index b5784895..397c4e86 100644 --- a/src/reactable/lib/filter_props_from.jsx +++ b/src/reactable/lib/filter_props_from.jsx @@ -1,4 +1,5 @@ const internalProps = { + hideTableHeader: true, column: true, columns: true, sortable: true, @@ -19,6 +20,9 @@ const internalProps = { hideFilterInput: true, noDataText: true, currentPage: true, + onPageChange: true, + previousPageLabel: true, + nextPageLabel: true, pageButtonLimit: true, childNode: true, data: true, @@ -36,4 +40,3 @@ export function filterPropsFrom(baseProps) { return props; } - diff --git a/src/reactable/thead.jsx b/src/reactable/thead.jsx index cb22821f..d484abea 100644 --- a/src/reactable/thead.jsx +++ b/src/reactable/thead.jsx @@ -9,6 +9,7 @@ export class Thead extends React.Component { let columns = []; React.Children.forEach(component.props.children, th => { var column = {}; + if (!th) return; if (typeof th.props !== 'undefined') { column.props = filterPropsFrom(th.props); diff --git a/src/reactable/tr.jsx b/src/reactable/tr.jsx index 483748ed..46219f73 100644 --- a/src/reactable/tr.jsx +++ b/src/reactable/tr.jsx @@ -14,10 +14,9 @@ export class Tr extends React.Component { ) { if (typeof(children.concat) === 'undefined') { console.log(children); } - children = children.concat(this.props.columns.map(function(column, i) { + children = children.concat(this.props.columns.map(function({ props = {}, ...column}, i) { if (this.props.data.hasOwnProperty(column.key)) { var value = this.props.data[column.key]; - var props = {}; if ( typeof(value) !== 'undefined' && From 4b35e4e49bca0322b6403eb283dc4b991fd237de Mon Sep 17 00:00:00 2001 From: huaying Date: Mon, 16 Oct 2017 20:53:23 -0700 Subject: [PATCH 3/3] add internal prop --- build/reactable.js | 4 +++- lib/reactable/lib/filter_props_from.js | 4 +++- src/reactable/lib/filter_props_from.jsx | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build/reactable.js b/build/reactable.js index 26ce94dc..2f197156 100644 --- a/build/reactable.js +++ b/build/reactable.js @@ -44,7 +44,9 @@ window.ReactDOM["default"] = window.ReactDOM; pageButtonLimit: true, childNode: true, data: true, - children: true + children: true, + onItemsPerPageChange: true, + rowOptions: true }; function filterPropsFrom(baseProps) { diff --git a/lib/reactable/lib/filter_props_from.js b/lib/reactable/lib/filter_props_from.js index b651549f..6ae44d03 100644 --- a/lib/reactable/lib/filter_props_from.js +++ b/lib/reactable/lib/filter_props_from.js @@ -32,7 +32,9 @@ var internalProps = { pageButtonLimit: true, childNode: true, data: true, - children: true + children: true, + onItemsPerPageChange: true, + rowOptions: true }; function filterPropsFrom(baseProps) { diff --git a/src/reactable/lib/filter_props_from.jsx b/src/reactable/lib/filter_props_from.jsx index 397c4e86..6c9d6d35 100644 --- a/src/reactable/lib/filter_props_from.jsx +++ b/src/reactable/lib/filter_props_from.jsx @@ -26,7 +26,9 @@ const internalProps = { pageButtonLimit: true, childNode: true, data: true, - children: true + children: true, + onItemsPerPageChange: true, + rowOptions: true }; export function filterPropsFrom(baseProps) {