From fa5aafb33a960e2a06a5b99486814d2aab85b84b Mon Sep 17 00:00:00 2001 From: Devin Chen Date: Sat, 3 Jun 2017 20:34:07 +0800 Subject: [PATCH] fix #2 Accessing PropTypes via the main React package is deprecated - Upgrade react to 15.5.x --- build/Column.js | 22 ++++++++------ build/ColumnGroup.js | 8 +++++- build/ExpandIcon.js | 16 +++++++---- build/Table.js | 68 +++++++++++++++++++++++--------------------- build/TableCell.js | 18 +++++++----- build/TableHeader.js | 10 +++++-- build/TableRow.js | 50 +++++++++++++++++--------------- demo/index.js | 2 +- package.json | 6 ++-- src/Column.js | 3 +- src/ColumnGroup.js | 3 +- src/ExpandIcon.js | 3 +- src/Table.js | 3 +- src/TableCell.js | 3 +- src/TableHeader.js | 3 +- src/TableRow.js | 3 +- 16 files changed, 130 insertions(+), 91 deletions(-) diff --git a/build/Column.js b/build/Column.js index 1511968..5d4fe3a 100644 --- a/build/Column.js +++ b/build/Column.js @@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", { var _react = require('react'); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -15,14 +21,14 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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) : _defaults(subClass, superClass); } var propTypes = { - className: _react.PropTypes.string, - colSpan: _react.PropTypes.number, - title: _react.PropTypes.node, - dataIndex: _react.PropTypes.string, - width: _react.PropTypes.oneOfType([_react.PropTypes.number, _react.PropTypes.string]), - fixed: _react.PropTypes.oneOf([true, 'left', 'right']), - render: _react.PropTypes.func, - onCellClick: _react.PropTypes.func + className: _propTypes2["default"].string, + colSpan: _propTypes2["default"].number, + title: _propTypes2["default"].node, + dataIndex: _propTypes2["default"].string, + width: _propTypes2["default"].oneOfType([_propTypes2["default"].number, _propTypes2["default"].string]), + fixed: _propTypes2["default"].oneOf([true, 'left', 'right']), + render: _propTypes2["default"].func, + onCellClick: _propTypes2["default"].func }; var Column = function (_Component) { diff --git a/build/ColumnGroup.js b/build/ColumnGroup.js index 5db83cd..e0dfb22 100644 --- a/build/ColumnGroup.js +++ b/build/ColumnGroup.js @@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", { var _react = require('react'); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } + function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -27,7 +33,7 @@ var ColumnGroup = function (_Component) { }(_react.Component); ColumnGroup.propTypes = { - title: _react.PropTypes.node + title: _propTypes2["default"].node }; exports["default"] = ColumnGroup; module.exports = exports['default']; \ No newline at end of file diff --git a/build/ExpandIcon.js b/build/ExpandIcon.js index c069e95..95387c5 100644 --- a/build/ExpandIcon.js +++ b/build/ExpandIcon.js @@ -8,6 +8,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _shallowequal = require('shallowequal'); var _shallowequal2 = _interopRequireDefault(_shallowequal); @@ -23,12 +27,12 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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) : _defaults(subClass, superClass); } var propTypes = { - record: _react.PropTypes.object, - clsPrefix: _react.PropTypes.string, - expandable: _react.PropTypes.any, - expanded: _react.PropTypes.bool, - needIndentSpaced: _react.PropTypes.bool, - onExpand: _react.PropTypes.func + record: _propTypes2["default"].object, + clsPrefix: _propTypes2["default"].string, + expandable: _propTypes2["default"].any, + expanded: _propTypes2["default"].bool, + needIndentSpaced: _propTypes2["default"].bool, + onExpand: _propTypes2["default"].func }; var ExpandIcon = function (_Component) { diff --git a/build/Table.js b/build/Table.js index 90da50b..98f957f 100644 --- a/build/Table.js +++ b/build/Table.js @@ -10,6 +10,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _TableRow = require('./TableRow'); var _TableRow2 = _interopRequireDefault(_TableRow); @@ -24,7 +28,7 @@ var _shallowequal = require('shallowequal'); var _shallowequal2 = _interopRequireDefault(_shallowequal); -var _addEventListener = require('rc-util/lib/Dom/addEventListener'); +var _addEventListener = require('tinper-bee-core/lib/addEventListener'); var _addEventListener2 = _interopRequireDefault(_addEventListener); @@ -49,36 +53,36 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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) : _defaults(subClass, superClass); } var propTypes = { - data: _react.PropTypes.array, - expandIconAsCell: _react.PropTypes.bool, - defaultExpandAllRows: _react.PropTypes.bool, - expandedRowKeys: _react.PropTypes.array, - defaultExpandedRowKeys: _react.PropTypes.array, - useFixedHeader: _react.PropTypes.bool, - columns: _react.PropTypes.array, - clsPrefix: _react.PropTypes.string, - bodyStyle: _react.PropTypes.object, - style: _react.PropTypes.object, + data: _propTypes2["default"].array, + expandIconAsCell: _propTypes2["default"].bool, + defaultExpandAllRows: _propTypes2["default"].bool, + expandedRowKeys: _propTypes2["default"].array, + defaultExpandedRowKeys: _propTypes2["default"].array, + useFixedHeader: _propTypes2["default"].bool, + columns: _propTypes2["default"].array, + clsPrefix: _propTypes2["default"].string, + bodyStyle: _propTypes2["default"].object, + style: _propTypes2["default"].object, //特殊的渲染规则的key值 - rowKey: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.func]), - rowClassName: _react.PropTypes.func, - expandedRowClassName: _react.PropTypes.func, - childrenColumnName: _react.PropTypes.string, - onExpand: _react.PropTypes.func, - onExpandedRowsChange: _react.PropTypes.func, - indentSize: _react.PropTypes.number, - onRowClick: _react.PropTypes.func, - onRowDoubleClick: _react.PropTypes.func, - expandIconColumnIndex: _react.PropTypes.number, + rowKey: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].func]), + rowClassName: _propTypes2["default"].func, + expandedRowClassName: _propTypes2["default"].func, + childrenColumnName: _propTypes2["default"].string, + onExpand: _propTypes2["default"].func, + onExpandedRowsChange: _propTypes2["default"].func, + indentSize: _propTypes2["default"].number, + onRowClick: _propTypes2["default"].func, + onRowDoubleClick: _propTypes2["default"].func, + expandIconColumnIndex: _propTypes2["default"].number, //是否显示表头 - showHeader: _react.PropTypes.bool, - title: _react.PropTypes.func, - footer: _react.PropTypes.func, - emptyText: _react.PropTypes.func, - scroll: _react.PropTypes.object, - rowRef: _react.PropTypes.func, - getBodyWrapper: _react.PropTypes.func, - children: _react.PropTypes.node + showHeader: _propTypes2["default"].bool, + title: _propTypes2["default"].func, + footer: _propTypes2["default"].func, + emptyText: _propTypes2["default"].func, + scroll: _propTypes2["default"].object, + rowRef: _propTypes2["default"].func, + getBodyWrapper: _propTypes2["default"].func, + children: _propTypes2["default"].node }; var defaultProps = { @@ -224,7 +228,7 @@ var Table = function (_Component) { this.props.onExpandedRowsChange(expandedRowKeys); }; - Table.prototype.onExpanded = function onExpanded(expanded, record, e, index) { + Table.prototype.onExpanded = function onExpanded(expanded, record, index, e) { if (e) { e.preventDefault(); e.stopPropagation(); @@ -276,7 +280,7 @@ var Table = function (_Component) { if (expandIconAsCell && fixed !== 'right') { rows[0].unshift({ - key: 'rc-table-expandIconAsCell', + key: 'u-table-expandIconAsCell', className: clsPrefix + '-expand-icon-th', title: '', rowSpan: rows.length @@ -470,7 +474,7 @@ var Table = function (_Component) { if (this.props.expandIconAsCell && fixed !== 'right') { cols.push(_react2["default"].createElement('col', { className: this.props.clsPrefix + '-expand-icon-col', - key: 'rc-table-expand-icon-col' + key: 'u-table-expand-icon-col' })); } var leafColumns = void 0; diff --git a/build/TableCell.js b/build/TableCell.js index e146272..fcb3d42 100644 --- a/build/TableCell.js +++ b/build/TableCell.js @@ -8,6 +8,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _objectPath = require('object-path'); var _objectPath2 = _interopRequireDefault(_objectPath); @@ -23,13 +27,13 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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) : _defaults(subClass, superClass); } var propTypes = { - record: _react.PropTypes.object, - clsPrefix: _react.PropTypes.string, - index: _react.PropTypes.number, - indent: _react.PropTypes.number, - indentSize: _react.PropTypes.number, - column: _react.PropTypes.object, - expandIcon: _react.PropTypes.node + record: _propTypes2["default"].object, + clsPrefix: _propTypes2["default"].string, + index: _propTypes2["default"].number, + indent: _propTypes2["default"].number, + indentSize: _propTypes2["default"].number, + column: _propTypes2["default"].object, + expandIcon: _propTypes2["default"].node }; var TableCell = function (_Component) { diff --git a/build/TableHeader.js b/build/TableHeader.js index 313ef27..7e69f70 100644 --- a/build/TableHeader.js +++ b/build/TableHeader.js @@ -10,6 +10,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _shallowequal = require('shallowequal'); var _shallowequal2 = _interopRequireDefault(_shallowequal); @@ -25,9 +29,9 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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) : _defaults(subClass, superClass); } var propTypes = { - clsPrefix: _react.PropTypes.string, - rowStyle: _react.PropTypes.object, - rows: _react.PropTypes.array + clsPrefix: _propTypes2["default"].string, + rowStyle: _propTypes2["default"].object, + rows: _propTypes2["default"].array }; var TableHeader = function (_Component) { diff --git a/build/TableRow.js b/build/TableRow.js index 5fbc13c..32bbd9a 100644 --- a/build/TableRow.js +++ b/build/TableRow.js @@ -8,6 +8,10 @@ var _react = require('react'); var _react2 = _interopRequireDefault(_react); +var _propTypes = require('prop-types'); + +var _propTypes2 = _interopRequireDefault(_propTypes); + var _TableCell = require('./TableCell'); var _TableCell2 = _interopRequireDefault(_TableCell); @@ -27,28 +31,28 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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) : _defaults(subClass, superClass); } var propTypes = { - onDestroy: _react.PropTypes.func, - onRowClick: _react.PropTypes.func, - onRowDoubleClick: _react.PropTypes.func, - record: _react.PropTypes.object, - clsPrefix: _react.PropTypes.string, - expandIconColumnIndex: _react.PropTypes.number, - onHover: _react.PropTypes.func, - columns: _react.PropTypes.array, - height: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.number]), - visible: _react.PropTypes.bool, - index: _react.PropTypes.number, - hoverKey: _react.PropTypes.any, - expanded: _react.PropTypes.bool, - expandable: _react.PropTypes.any, - onExpand: _react.PropTypes.func, - needIndentSpaced: _react.PropTypes.bool, - className: _react.PropTypes.string, - indent: _react.PropTypes.number, - indentSize: _react.PropTypes.number, - expandIconAsCell: _react.PropTypes.bool, - expandRowByClick: _react.PropTypes.bool, - store: _react.PropTypes.object.isRequired + onDestroy: _propTypes2["default"].func, + onRowClick: _propTypes2["default"].func, + onRowDoubleClick: _propTypes2["default"].func, + record: _propTypes2["default"].object, + clsPrefix: _propTypes2["default"].string, + expandIconColumnIndex: _propTypes2["default"].number, + onHover: _propTypes2["default"].func, + columns: _propTypes2["default"].array, + height: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].number]), + visible: _propTypes2["default"].bool, + index: _propTypes2["default"].number, + hoverKey: _propTypes2["default"].any, + expanded: _propTypes2["default"].bool, + expandable: _propTypes2["default"].any, + onExpand: _propTypes2["default"].func, + needIndentSpaced: _propTypes2["default"].bool, + className: _propTypes2["default"].string, + indent: _propTypes2["default"].number, + indentSize: _propTypes2["default"].number, + expandIconAsCell: _propTypes2["default"].bool, + expandRowByClick: _propTypes2["default"].bool, + store: _propTypes2["default"].object.isRequired }; var defaultProps = { @@ -119,7 +123,7 @@ var TableRow = function (_Component) { onExpand = _props3.onExpand; if (expandable && expandRowByClick) { - onExpand(!expanded, record, index); + onExpand(!expanded, record, index, event); } onRowClick(record, index, event); }; diff --git a/demo/index.js b/demo/index.js index 3d24f57..e3778c4 100644 --- a/demo/index.js +++ b/demo/index.js @@ -274,7 +274,7 @@ class Demo3 extends Component { ) } } -var DemoArray = [{"example":,"title":" 简单表格","code":"/**\n*\n* @title 简单表格\n* @description\n*\n*/\n\nconst columns = [\n { title: '用户名', dataIndex: 'a', key: 'a', width: 100 },\n { id: '123', title: '性别', dataIndex: 'b', key: 'b', width: 100 },\n { title: '年龄', dataIndex: 'c', key: 'c', width: 200 },\n {\n title: '操作', dataIndex: '', key: 'd', render() {\n return 一些操作;\n },\n },\n];\n\nconst data = [\n { a: '令狐冲', b: '男', c: 41, key: '1' },\n { a: '杨过', b: '男', c: 67, key: '2' },\n { a: '郭靖', b: '男', c: 25, key: '3' },\n];\n\nclass Demo1 extends Component {\n render () {\n return (\n
标题: 这是一个标题
}\n footer={currentData =>
表尾: 我是小尾巴
}\n />\n )\n }\n}\n","desc":""},{"example":,"title":" 增删改表格","code":"/**\n*\n* @title 增删改表格\n* @description 这是带有增删改功能的表格\n*\n*/\n\nclass EditableCell extends React.Component {\n state = {\n value: this.props.value,\n editable: false,\n }\n handleChange = (e) => {\n const value = e.target.value;\n this.setState({ value });\n }\n check = () => {\n this.setState({ editable: false });\n if (this.props.onChange) {\n this.props.onChange(this.state.value);\n }\n }\n edit = () => {\n this.setState({ editable: true });\n }\n handleKeydown = (event) => {\n console.log(event.keyCode);\n if(event.keyCode == 13){\n this.check();\n }\n\n }\n render() {\n const { value, editable } = this.state;\n return (
\n {\n editable ?\n
\n \n \n
\n :\n
\n {value || ' '}\n \n
\n }\n
);\n }\n}\n\nclass Demo2 extends React.Component {\n constructor(props) {\n super(props);\n this.columns = [{\n title: '姓名',\n dataIndex: 'name',\n key:'name',\n width: '30%',\n render: (text, record, index) => (\n \n ),\n }, {\n title: '年龄',\n dataIndex: 'age',\n key:'age',\n }, {\n title: '你懂的',\n dataIndex: 'address',\n key:'address',\n }, {\n title: '操作',\n dataIndex: 'operation',\n key: 'operation',\n render: (text, record, index) => {\n return (\n this.state.dataSource.length > 1 ?\n (\n \n \n \n ) : null\n );\n },\n }];\n\n this.state = {\n dataSource: [{\n key: '0',\n name: '沉鱼',\n age: '18',\n address: '96, 77, 89',\n }, {\n key: '1',\n name: '落雁',\n age: '16',\n address: '90, 70, 80',\n }, {\n key: '2',\n name: '闭月',\n age: '17',\n address: '80, 60, 80',\n }, {\n key: '3',\n name: '羞花',\n age: '20',\n address: '120, 60, 90',\n }],\n count: 4,\n };\n }\n onCellChange = (index, key) => {\n return (value) => {\n const dataSource = [...this.state.dataSource];\n dataSource[index][key] = value;\n this.setState({ dataSource });\n };\n }\n onDelete = (index) => {\n return () => {\n const dataSource = [...this.state.dataSource];\n dataSource.splice(index, 1);\n this.setState({ dataSource });\n };\n }\n handleAdd = () => {\n const { count, dataSource } = this.state;\n const newData = {\n key: count,\n name: `凤姐 ${count}`,\n age: 32,\n address: `100 100 100`,\n };\n this.setState({\n dataSource: [...dataSource, newData],\n count: count + 1,\n });\n }\n\n getBodyWrapper = (body) => {\n return (\n \n {body.props.children}\n \n );\n }\n render() {\n const { dataSource } = this.state;\n const columns = this.columns;\n return (
\n \n \n );\n }\n}\n","desc":" 这是带有增删改功能的表格"},{"example":,"title":" 更灵活的表格","code":"/**\r\n*\r\n* @title 更灵活的表格\r\n* @description 手写表格的头组件来达到更灵活的配置表格\r\n*\r\n*/\r\n\r\nconst { ColumnGroup, Column } = Table;\r\n\r\nconst data3 = [\r\n { a: '北京', b: '北京', c: '250', d: 2, key: '1' },\r\n];\r\n\r\nclass Demo3 extends Component {\r\n render () {\r\n return (\r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n {\r\n return (\r\n \r\n );\r\n }}\r\n />\r\n
\r\n )\r\n }\r\n}\r\n","desc":" 手写表格的头组件来达到更灵活的配置表格"}] +var DemoArray = [{"example":,"title":" 简单表格","code":"/**\n*\n* @title 简单表格\n* @description\n*\n*/\n\nconst columns = [\n { title: '用户名', dataIndex: 'a', key: 'a', width: 100 },\n { id: '123', title: '性别', dataIndex: 'b', key: 'b', width: 100 },\n { title: '年龄', dataIndex: 'c', key: 'c', width: 200 },\n {\n title: '操作', dataIndex: '', key: 'd', render() {\n return 一些操作;\n },\n },\n];\n\nconst data = [\n { a: '令狐冲', b: '男', c: 41, key: '1' },\n { a: '杨过', b: '男', c: 67, key: '2' },\n { a: '郭靖', b: '男', c: 25, key: '3' },\n];\n\nclass Demo1 extends Component {\n render () {\n return (\n
标题: 这是一个标题
}\n footer={currentData =>
表尾: 我是小尾巴
}\n />\n )\n }\n}\n","desc":""},{"example":,"title":" 增删改表格","code":"/**\n*\n* @title 增删改表格\n* @description 这是带有增删改功能的表格\n*\n*/\n\nclass EditableCell extends React.Component {\n state = {\n value: this.props.value,\n editable: false,\n }\n handleChange = (e) => {\n const value = e.target.value;\n this.setState({ value });\n }\n check = () => {\n this.setState({ editable: false });\n if (this.props.onChange) {\n this.props.onChange(this.state.value);\n }\n }\n edit = () => {\n this.setState({ editable: true });\n }\n handleKeydown = (event) => {\n console.log(event.keyCode);\n if(event.keyCode == 13){\n this.check();\n }\n\n }\n render() {\n const { value, editable } = this.state;\n return (
\n {\n editable ?\n
\n \n \n
\n :\n
\n {value || ' '}\n \n
\n }\n
);\n }\n}\n\nclass Demo2 extends React.Component {\n constructor(props) {\n super(props);\n this.columns = [{\n title: '姓名',\n dataIndex: 'name',\n key:'name',\n width: '30%',\n render: (text, record, index) => (\n \n ),\n }, {\n title: '年龄',\n dataIndex: 'age',\n key:'age',\n }, {\n title: '你懂的',\n dataIndex: 'address',\n key:'address',\n }, {\n title: '操作',\n dataIndex: 'operation',\n key: 'operation',\n render: (text, record, index) => {\n return (\n this.state.dataSource.length > 1 ?\n (\n \n \n \n ) : null\n );\n },\n }];\n\n this.state = {\n dataSource: [{\n key: '0',\n name: '沉鱼',\n age: '18',\n address: '96, 77, 89',\n }, {\n key: '1',\n name: '落雁',\n age: '16',\n address: '90, 70, 80',\n }, {\n key: '2',\n name: '闭月',\n age: '17',\n address: '80, 60, 80',\n }, {\n key: '3',\n name: '羞花',\n age: '20',\n address: '120, 60, 90',\n }],\n count: 4,\n };\n }\n onCellChange = (index, key) => {\n return (value) => {\n const dataSource = [...this.state.dataSource];\n dataSource[index][key] = value;\n this.setState({ dataSource });\n };\n }\n onDelete = (index) => {\n return () => {\n const dataSource = [...this.state.dataSource];\n dataSource.splice(index, 1);\n this.setState({ dataSource });\n };\n }\n handleAdd = () => {\n const { count, dataSource } = this.state;\n const newData = {\n key: count,\n name: `凤姐 ${count}`,\n age: 32,\n address: `100 100 100`,\n };\n this.setState({\n dataSource: [...dataSource, newData],\n count: count + 1,\n });\n }\n\n getBodyWrapper = (body) => {\n return (\n \n {body.props.children}\n \n );\n }\n render() {\n const { dataSource } = this.state;\n const columns = this.columns;\n return (
\n \n \n );\n }\n}\n","desc":" 这是带有增删改功能的表格"},{"example":,"title":" 更灵活的表格","code":"/**\n*\n* @title 更灵活的表格\n* @description 手写表格的头组件来达到更灵活的配置表格\n*\n*/\n\nconst { ColumnGroup, Column } = Table;\n\nconst data3 = [\n { a: '北京', b: '北京', c: '250', d: 2, key: '1' },\n];\n\nclass Demo3 extends Component {\n render () {\n return (\n\n
\n \n \n \n \n \n {\n return (\n \n );\n }}\n />\n
\n )\n }\n}\n","desc":" 手写表格的头组件来达到更灵活的配置表格"}] class Demo extends Component { diff --git a/package.json b/package.json index 289624d..9c5407c 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "console-polyfill": "~0.2.1", "enzyme": "^2.4.1", "es5-shim": "~4.1.10", - "react": "15.3.2", - "react-addons-test-utils": "15.3.2", - "react-dom": "15.3.2" + "react": "^15.5.0", + "react-addons-test-utils": "^15.5.0", + "react-dom": "^15.5.0" } } diff --git a/src/Column.js b/src/Column.js index e73f633..9a4a758 100644 --- a/src/Column.js +++ b/src/Column.js @@ -1,4 +1,5 @@ -import { Component, PropTypes } from 'react'; +import { Component } from 'react'; +import PropTypes from 'prop-types'; const propTypes = { className: PropTypes.string, diff --git a/src/ColumnGroup.js b/src/ColumnGroup.js index 6ea54a0..7710baf 100644 --- a/src/ColumnGroup.js +++ b/src/ColumnGroup.js @@ -1,4 +1,5 @@ -import { Component, PropTypes } from 'react'; +import { Component } from 'react'; +import PropTypes from 'prop-types'; export default class ColumnGroup extends Component { static propTypes = { diff --git a/src/ExpandIcon.js b/src/ExpandIcon.js index 3ce20d6..39d59a2 100644 --- a/src/ExpandIcon.js +++ b/src/ExpandIcon.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import shallowequal from 'shallowequal'; const propTypes = { diff --git a/src/Table.js b/src/Table.js index a0802f2..ecfec7d 100644 --- a/src/Table.js +++ b/src/Table.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import TableRow from './TableRow'; import TableHeader from './TableHeader'; import { measureScrollbar, debounce, warningOnce } from './utils'; diff --git a/src/TableCell.js b/src/TableCell.js index eedeac0..8a3ed23 100644 --- a/src/TableCell.js +++ b/src/TableCell.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import objectPath from 'object-path'; const propTypes = { diff --git a/src/TableHeader.js b/src/TableHeader.js index ecfda62..2ae2b95 100644 --- a/src/TableHeader.js +++ b/src/TableHeader.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import shallowequal from 'shallowequal'; const propTypes = { diff --git a/src/TableRow.js b/src/TableRow.js index b836262..1c5a1ec 100644 --- a/src/TableRow.js +++ b/src/TableRow.js @@ -1,4 +1,5 @@ -import React, { PropTypes, Component } from 'react'; +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; import TableCell from './TableCell'; import ExpandIcon from './ExpandIcon';