From 159cfe09c421b115a2ee04be43762899af0df20b Mon Sep 17 00:00:00 2001 From: 2betop Date: Wed, 24 Feb 2016 06:57:26 +0000 Subject: [PATCH] rm all files --- README.md | 270 ------------------------------------------- assets/index.css | 62 ---------- component.json | 9 -- lib/Table.js | 294 ----------------------------------------------- lib/TableRow.js | 97 ---------------- lib/index.js | 3 - 6 files changed, 735 deletions(-) delete mode 100644 README.md delete mode 100644 assets/index.css delete mode 100644 component.json delete mode 100644 lib/Table.js delete mode 100644 lib/TableRow.js delete mode 100644 lib/index.js diff --git a/README.md b/README.md deleted file mode 100644 index 5033a02..0000000 --- a/README.md +++ /dev/null @@ -1,270 +0,0 @@ -# rc-table - -react table component - -[![NPM version][npm-image]][npm-url] -[![build status][travis-image]][travis-url] -[![Test coverage][coveralls-image]][coveralls-url] -[![gemnasium deps][gemnasium-image]][gemnasium-url] -[![node version][node-image]][node-url] -[![npm download][download-image]][download-url] - -[npm-image]: http://img.shields.io/npm/v/rc-table.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-table -[travis-image]: https://img.shields.io/travis/react-component/table.svg?style=flat-square -[travis-url]: https://travis-ci.org/react-component/table -[coveralls-image]: https://img.shields.io/coveralls/react-component/table.svg?style=flat-square -[coveralls-url]: https://coveralls.io/r/react-component/table?branch=master -[gemnasium-image]: http://img.shields.io/gemnasium/react-component/table.svg?style=flat-square -[gemnasium-url]: https://gemnasium.com/react-component/table -[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square -[node-url]: http://nodejs.org/download/ -[download-image]: https://img.shields.io/npm/dm/rc-table.svg?style=flat-square -[download-url]: https://npmjs.org/package/rc-table - -## install - -[![rc-table](https://nodei.co/npm/rc-table.png)](https://npmjs.org/package/rc-table) - - -## Development - -``` -npm install -npm start -``` - -## Example - -http://localhost:8000/examples/ - -online example: http://react-component.github.io/table/examples/ - -## Usage - -```js -var React = require('react'); -var Table = require('rc-table'); -require('rc-table/assets/index.css'); - -var columns = [ - {title: '表头1', dataIndex: 'a', colSpan: 2,key:'a',width: 100}, - {id: '123', title: '表头2', dataIndex: 'b', colSpan: 0,key:'b', width: 100, render: function(o, row, index){ - let obj ={ - children:o, - props:{} - } - if(index === 0){ - obj.props.rowSpan = 2; - } - if(index === 1){ - obj.props.rowSpan = 0; - } - return obj; - }}, - {title: '表头3', dataIndex: 'c', key:'c',width: 200}, - { - title: '操作', dataIndex: '', key:'d',render: function () { - return 操作 - } - } -]; - -var data = [{a: '123',key:'1'}, {a: 'cdd', b: 'edd',key:'2'}, {a: '1333', c: 'eee', d: 2,key:'3'}]; - -var table = React.render( -
-

simple table

- - , - document.getElementById('__react-content') -); -``` -## API - -### property - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nametypedefaultdescription
prefixClsStringrc-table
classNameStringadditional className
colSpanNumberthead colSpan of this column
useFixedHeaderBooleanfalsewhether use separator table for header. better set width for columns
expandIconAsCellBooleanfalsewhether render expandIcon as a cell
expandIconColumnIndexNumber0The index of expandIcon which column will be inserted when expandIconAsCell is false
rowKeyFunction(recode,index):stringrecord.keydefault use record.key as rowKey
rowClassNameFunction(recode,index):stringget row's className
defaultExpandedRowKeysString[][]initial expanded rows keys
expandedRowKeysString[]current expanded rows keys
onExpandedRowsChangeFunction(expandedRows)save the expanded rows in the internal statefunction to call when the expanded rows change
expandedRowClassNameFunction(recode,index):stringget expanded row's className
dataObject[]data record array to be rendered
indentSizeNumber15indentSize for every level of data.i.children, better using with column.width specified
onRowClickFunction(record, index)handle rowClick action, index means the index of current row among fatherElement[childrenColumnName]
columnsPageRangeArraycolumns index range need paging, like [2,10]
columnsPageSizeNumber5pageSize of columns
columnsObject[] - The columns config of table. contains - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
nametypedefaultdescription
keyStringkey of this column
classNameStringclassName of this column
titleReact Nodetitle of this column
dataIndexStringdisplay field of the data record
widthString|Numberhe width of the specific proportion calculation according to the width of the columns
renderFunction(value, row, index)The render function of cell, has three params: the text of this cell, the record of this row, the index of this row, it's return an object:{children: value, props:{colSpan: 1, rowSpan:1}}==>'children' is the text of this cell, props is some setting of this cell, eg: 'colspan' set td colspan, 'rowspan' set td rowspan
-
- -## Test Case - -http://localhost:8000/tests/runner.html?coverage - -## Coverage - -http://localhost:8000/node_modules/rc-server/node_modules/node-jscover/lib/front-end/jscoverage.html?w=http://localhost:8000/tests/runner.html?coverage - -## License - -rc-table is released under the MIT license. diff --git a/assets/index.css b/assets/index.css deleted file mode 100644 index dc0eeba..0000000 --- a/assets/index.css +++ /dev/null @@ -1,62 +0,0 @@ -.rc-table { - font-size: 12px; - color: #666; - border-radius: 6px; - transition: opacity 0.3s ease; -} -.rc-table table { - width: 100%; - max-width: 100%; - border-collapse: separate; - text-align: left; -} -.rc-table th { - background: #f3f3f3; - font-weight: bold; - transition: background .3s ease; -} -.rc-table th:first-child { - border-radius: 6px 0 0 0; -} -.rc-table th:last-child { - border-radius: 0 6px 0 0; -} -.rc-table td { - border-bottom: 1px solid #e9e9e9; -} -.rc-table tr { - transition: all .3s ease; -} -.rc-table tr:hover { - background: #eaf8fe; -} -.rc-table th, -.rc-table td { - padding: 16px 8px; -} -.rc-table-expand-icon-col { - width: 10px; -} -.rc-table-row-expand-icon, -.rc-table-expanded-row-expand-icon { - cursor: pointer; - display: inline-block; - margin: 5px; - width: 21px; - height: 28px; - text-align: center; - line-height: 28px; - border: 1px solid red; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.rc-table-row-expanded:after, -.rc-table-expanded-row-expanded:after { - content: '-'; -} -.rc-table-row-collapsed:after, -.rc-table-expanded-row-collapsed:after { - content: '+'; -} diff --git a/component.json b/component.json deleted file mode 100644 index 786c6ca..0000000 --- a/component.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "rc-table", - "description": "table ui component for react", - "repos": "https://github.com/react-component/table.git", - "main": "./lib/index", - "tag": "master", - "reposType": "npm", - "version": "3.6.0" -} \ No newline at end of file diff --git a/lib/Table.js b/lib/Table.js deleted file mode 100644 index d0b82c5..0000000 --- a/lib/Table.js +++ /dev/null @@ -1,294 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var _TableRow = require('./TableRow'); - -var _TableRow2 = _interopRequireDefault(_TableRow); - -var Table = _react2['default'].createClass({ - displayName: 'Table', - - propTypes: { - data: _react2['default'].PropTypes.array, - expandIconAsCell: _react2['default'].PropTypes.bool, - expandedRowKeys: _react2['default'].PropTypes.array, - defaultExpandedRowKeys: _react2['default'].PropTypes.array, - useFixedHeader: _react2['default'].PropTypes.bool, - columns: _react2['default'].PropTypes.array, - prefixCls: _react2['default'].PropTypes.string, - bodyStyle: _react2['default'].PropTypes.object, - style: _react2['default'].PropTypes.object, - rowKey: _react2['default'].PropTypes.func, - rowClassName: _react2['default'].PropTypes.func, - expandedRowClassName: _react2['default'].PropTypes.func, - childrenColumnName: _react2['default'].PropTypes.string, - onExpandedRowsChange: _react2['default'].PropTypes.func - }, - - getDefaultProps: function getDefaultProps() { - return { - data: [], - useFixedHeader: false, - expandIconAsCell: false, - columns: [], - defaultExpandedRowKeys: [], - rowKey: function rowKey(o) { - return o.key; - }, - rowClassName: function rowClassName() { - return ''; - }, - expandedRowClassName: function expandedRowClassName() { - return ''; - }, - prefixCls: 'rc-table', - bodyStyle: {}, - style: {}, - childrenColumnName: 'children' - }; - }, - - getInitialState: function getInitialState() { - var props = this.props; - return { - expandedRowKeys: props.expandedRowKeys || props.defaultExpandedRowKeys, - data: this.props.data - }; - }, - - componentWillReceiveProps: function componentWillReceiveProps(nextProps) { - if ('data' in nextProps) { - this.setState({ - data: nextProps.data - }); - } - if ('expandedRowKeys' in nextProps) { - this.setState({ - expandedRowKeys: nextProps.expandedRowKeys - }); - } - }, - - onExpandedRowsChange: function onExpandedRowsChange(expandedRowKeys) { - if (!this.props.expandedRowKeys) { - this.setState({ - expandedRowKeys: expandedRowKeys - }); - } - this.props.onExpandedRowsChange(expandedRowKeys); - }, - - onExpanded: function onExpanded(expanded, record) { - var info = this.findExpandedRow(record); - if (info && !expanded) { - this.onRowDestroy(record); - } else if (!info && expanded) { - var expandedRows = this.getExpandedRows().concat(); - expandedRows.push(this.props.rowKey(record)); - this.onExpandedRowsChange(expandedRows); - } - }, - - onRowDestroy: function onRowDestroy(record) { - var expandedRows = this.getExpandedRows().concat(); - var rowKey = this.props.rowKey(record); - var index = -1; - expandedRows.forEach(function (r, i) { - if (r === rowKey) { - index = i; - } - }); - if (index !== -1) { - expandedRows.splice(index, 1); - } - this.onExpandedRowsChange(expandedRows); - }, - - getExpandedRows: function getExpandedRows() { - return this.props.expandedRowKeys || this.state.expandedRowKeys; - }, - - getThs: function getThs() { - var ths = []; - if (this.props.expandIconAsCell) { - ths.push({ - key: 'rc-table-expandIconAsCell', - className: this.props.prefixCls + '-expand-icon-th', - title: '' - }); - } - ths = ths.concat(this.props.columns); - return ths.map(function (c) { - if (c.colSpan !== 0) { - return _react2['default'].createElement( - 'th', - { key: c.key, colSpan: c.colSpan, className: c.className || '' }, - c.title - ); - } - }); - }, - - getExpandedRow: function getExpandedRow(key2, content, visible, className) { - var key = key2; - var prefixCls = this.props.prefixCls; - if (key) { - key += '-extra-row'; - } - return _react2['default'].createElement( - 'tr', - { key: key, style: { display: visible ? '' : 'none' }, className: prefixCls + '-expanded-row ' + className }, - this.props.expandIconAsCell ? _react2['default'].createElement('td', { key: 'rc-table-expand-icon-placeholder' }) : '', - _react2['default'].createElement( - 'td', - { colSpan: this.props.columns.length }, - content - ) - ); - }, - - getRowsByData: function getRowsByData(data, visible) { - var props = this.props; - var columns = props.columns; - var childrenColumnName = props.childrenColumnName; - var expandedRowRender = props.expandedRowRender; - var expandIconAsCell = props.expandIconAsCell; - var rst = []; - var keyFn = props.rowKey; - var rowClassName = props.rowClassName; - var expandedRowClassName = props.expandedRowClassName; - for (var i = 0; i < data.length; i++) { - var record = data[i]; - var key = keyFn ? keyFn(record, i) : undefined; - var childrenColumn = record[childrenColumnName]; - var isRowExpanded = this.isRowExpanded(record); - var expandedRowContent = undefined; - if (expandedRowRender) { - expandedRowContent = expandedRowRender(record, i); - } - var className = rowClassName(record, i); - rst.push(_react2['default'].createElement(_TableRow2['default'], { - className: className, - record: record, - expandIconAsCell: expandIconAsCell, - onDestroy: this.onRowDestroy, - index: i, - visible: visible, - onExpand: this.onExpanded, - expandable: childrenColumn || expandedRowContent, - expanded: isRowExpanded, - prefixCls: props.prefixCls + '-row', - childrenColumnName: childrenColumnName, - columns: columns, - key: key })); - - var subVisible = visible && isRowExpanded; - - if (expandedRowContent && isRowExpanded) { - rst.push(this.getExpandedRow(key, expandedRowContent, subVisible, expandedRowClassName(record, i))); - } - if (childrenColumn) { - rst = rst.concat(this.getRowsByData(childrenColumn, subVisible)); - } - } - return rst; - }, - - getRows: function getRows() { - return this.getRowsByData(this.state.data, true); - }, - - getColGroup: function getColGroup() { - var cols = []; - if (this.props.expandIconAsCell) { - cols.push(_react2['default'].createElement('col', { className: this.props.prefixCls + '-expand-icon-col', key: 'rc-table-expand-icon-col' })); - } - cols = cols.concat(this.props.columns.map(function (c) { - return _react2['default'].createElement('col', { key: c.key, style: { width: c.width } }); - })); - return _react2['default'].createElement( - 'colgroup', - null, - cols - ); - }, - - findExpandedRow: function findExpandedRow(record) { - var keyFn = this.props.rowKey; - var currentRowKey = keyFn(record); - var rows = this.getExpandedRows().filter(function (i) { - return i === currentRowKey; - }); - return rows[0] || null; - }, - - isRowExpanded: function isRowExpanded(record) { - return !!this.findExpandedRow(record); - }, - - render: function render() { - var props = this.props; - var prefixCls = props.prefixCls; - var columns = this.getThs(); - var rows = this.getRows(); - var className = props.prefixCls; - if (props.className) { - className += ' ' + props.className; - } - var headerTable = undefined; - var thead = _react2['default'].createElement( - 'thead', - { className: prefixCls + '-thead' }, - _react2['default'].createElement( - 'tr', - null, - columns - ) - ); - if (props.useFixedHeader) { - headerTable = _react2['default'].createElement( - 'div', - { className: prefixCls + '-header' }, - _react2['default'].createElement( - 'table', - null, - this.getColGroup(), - thead - ) - ); - thead = null; - } - return _react2['default'].createElement( - 'div', - { className: className, style: props.style }, - headerTable, - _react2['default'].createElement( - 'div', - { className: prefixCls + '-body', style: props.bodyStyle }, - _react2['default'].createElement( - 'table', - null, - this.getColGroup(), - thead, - _react2['default'].createElement( - 'tbody', - { className: prefixCls + '-tbody' }, - rows - ) - ) - ) - ); - } -}); - -exports['default'] = Table; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/TableRow.js b/lib/TableRow.js deleted file mode 100644 index 4ff9470..0000000 --- a/lib/TableRow.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, '__esModule', { - value: true -}); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -var _react = require('react'); - -var _react2 = _interopRequireDefault(_react); - -var TableRow = _react2['default'].createClass({ - displayName: 'TableRow', - - propTypes: { - onDestroy: _react2['default'].PropTypes.func, - record: _react2['default'].PropTypes.object, - prefixCls: _react2['default'].PropTypes.string - }, - - componentWillUnmount: function componentWillUnmount() { - this.props.onDestroy(this.props.record); - }, - - render: function render() { - var props = this.props; - var prefixCls = props.prefixCls; - var columns = props.columns; - var record = props.record; - var index = props.index; - var cells = []; - var expanded = props.expanded; - var expandable = props.expandable; - var expandIconAsCell = props.expandIconAsCell; - - for (var i = 0; i < columns.length; i++) { - var col = columns[i]; - var colClassName = col.className || ''; - var render = col.render; - var text = record[col.dataIndex]; - - var expandIcon = null; - var tdProps = undefined; - var colSpan = undefined; - var rowSpan = undefined; - var notRender = false; - - if (i === 0 && expandable) { - expandIcon = _react2['default'].createElement('span', { - className: prefixCls + '-expand-icon ' + prefixCls + '-' + (expanded ? 'expanded' : 'collapsed'), - onClick: props.onExpand.bind(null, !expanded, record) }); - } - - if (expandIconAsCell && i === 0) { - cells.push(_react2['default'].createElement( - 'td', - { className: prefixCls + '-expand-icon-cell', - key: 'rc-table-expand-icon-cell' }, - expandIcon - )); - expandIcon = null; - } - - if (render) { - text = render(text, record, index) || {}; - tdProps = text.props || {}; - - if (!_react2['default'].isValidElement(text)) { - text = text.children; - } - rowSpan = tdProps.rowSpan; - colSpan = tdProps.colSpan; - } - - if (rowSpan === 0 || colSpan === 0) { - notRender = true; - } - if (!notRender) { - cells.push(_react2['default'].createElement( - 'td', - { key: col.key, colSpan: colSpan, rowSpan: rowSpan, className: '' + colClassName }, - expandIcon, - text - )); - } - } - return _react2['default'].createElement( - 'tr', - { className: prefixCls + ' ' + props.className, style: { display: props.visible ? '' : 'none' } }, - cells - ); - } -}); - -exports['default'] = TableRow; -module.exports = exports['default']; \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8591a71..0000000 --- a/lib/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./Table'); \ No newline at end of file