fast-table
Advanced tools
Comparing version 1.3.13 to 1.4.0
@@ -17,6 +17,2 @@ 'use strict'; | ||
var _classnames = require('classnames'); | ||
var _classnames2 = _interopRequireDefault(_classnames); | ||
var _TableHeader = require('./TableHeader'); | ||
@@ -36,6 +32,8 @@ | ||
var _TableCell = require('./TableCell'); | ||
var _TableCell2 = _interopRequireDefault(_TableCell); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -97,6 +95,8 @@ | ||
hoverEnable = _table$props.hoverEnable; | ||
var dataManager = table.dataManager, | ||
sizeManager = table.sizeManager, | ||
cacheManager = table.cacheManager, | ||
columnManager = table.columnManager; | ||
var dataManager = table.dataManager; | ||
var sizeManager = table.sizeManager; | ||
var columns = table.columnManager.bodyColumns(fixed); | ||
var columns = columnManager.bodyColumns(fixed); | ||
var hasExpanded = dataManager._hasExpanded; | ||
@@ -113,16 +113,40 @@ var showData = dataManager.showData(); | ||
for (var _iterator = dataSource[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _classNames; | ||
var record = _step.value; | ||
var key = 'Row' + record._path; | ||
var cells = []; | ||
for (var i = 0; i < columns.length; i++) { | ||
var cellKey = 'Row' + record._path + '-Col' + i + '_' + fixed; | ||
var cell = cacheManager.getCell(cellKey); | ||
if (!cell || record._isFixed) { | ||
var cellProps = { | ||
key: cellKey, | ||
column: columns[i], | ||
record: record, | ||
components: table.components | ||
}; | ||
if (hasExpanded) { | ||
cellProps.ExpandedIcon = (0, _ExpandedIcon2.default)({ | ||
columnIndex: i, | ||
record: record, | ||
prefixCls: prefixCls, | ||
fixed: fixed, | ||
indentSize: indentSize, | ||
handleExpanded: handleExpandChange | ||
}); | ||
} | ||
cacheManager.setCell(cellKey, (0, _TableCell2.default)(cellProps)); | ||
cell = cacheManager.getCell(cellKey); | ||
} | ||
cells.push(cell); | ||
} | ||
var className = typeof rowClassName === 'function' ? rowClassName(record, record._index) : rowClassName; | ||
var _props = { | ||
key: 'Row' + record._showIndex, | ||
className: (0, _classnames2.default)(className, (_classNames = {}, _defineProperty(_classNames, prefixCls + '-hover', currentHoverKey === record.key), _defineProperty(_classNames, prefixCls + '-expanded-row-' + record._expandedLevel, hasExpanded), _defineProperty(_classNames, prefixCls + '-row-fixed', record._isFixed), _classNames)), | ||
key: key, | ||
className: className, | ||
hasExpanded: hasExpanded, | ||
record: record, | ||
prefixCls: prefixCls, | ||
columns: columns, | ||
fixed: fixed, | ||
expandedRowByClick: expandedRowByClick, | ||
expanded: dataManager.rowIsExpanded(record), | ||
onHover: _this.handleRowHover, | ||
@@ -132,6 +156,6 @@ components: table.components, | ||
hoverEnable: hoverEnable, | ||
indentSize: indentSize, | ||
scrollTop: sizeManager._scrollTop | ||
scrollTop: sizeManager._scrollTop, | ||
hovered: currentHoverKey === record.key, | ||
cells: cells | ||
}; | ||
hasExpanded && (_props.renderExpandedIcon = _ExpandedIcon2.default); | ||
rows.push((0, _TableRow2.default)(_props)); | ||
@@ -138,0 +162,0 @@ } |
@@ -19,4 +19,3 @@ 'use strict'; | ||
function ExpandedIcon(props) { | ||
var expanded = props.expanded, | ||
prefixCls = props.prefixCls, | ||
var prefixCls = props.prefixCls, | ||
record = props.record, | ||
@@ -26,3 +25,3 @@ onClick = props.onClick; | ||
var newProps = { | ||
className: (0, _classnames2.default)(prefixCls + '-expanded-icon', { expanded: expanded }), | ||
className: (0, _classnames2.default)(prefixCls + '-expanded-icon', { expanded: record._expanded }), | ||
onClick: function (_onClick) { | ||
@@ -51,3 +50,2 @@ function onClick(_x) { | ||
fixed = props.fixed, | ||
expanded = props.expanded, | ||
indentSize = props.indentSize, | ||
@@ -65,3 +63,2 @@ handleExpanded = props.handleExpanded; | ||
rowKey: record.key, | ||
expanded: expanded, | ||
onClick: handleExpanded | ||
@@ -68,0 +65,0 @@ }); |
@@ -125,2 +125,3 @@ 'use strict'; | ||
var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var parentPath = arguments[2]; | ||
@@ -130,3 +131,5 @@ dataSource = dataSource || []; | ||
var height = _this.getRowHeight(dataSource[index], index) * _this.rowHeight; | ||
var path = '' + (parentPath === undefined ? index : parentPath + '-' + index); | ||
dataSource[index]['_index'] = index; | ||
dataSource[index]['_path'] = path; | ||
dataSource[index]['_expandedLevel'] = level; | ||
@@ -142,3 +145,3 @@ dataSource[index]['_height'] = height; | ||
if (children.length > 0) { | ||
dataSource[index]['children'] = _this._getData(children, level + 1); | ||
dataSource[index]['children'] = _this._getData(children, level + 1, path); | ||
} | ||
@@ -168,4 +171,6 @@ } | ||
var children = record.children || []; | ||
var _expanded = expandedKeys.length > 0 && expandedKeys.indexOf(record.key) > -1 && children.length > 0; | ||
record._expanded = _expanded; | ||
data.push(record); | ||
if (expandedKeys.length > 0 && expandedKeys.indexOf(record.key) > -1 && children.length > 0) { | ||
if (_expanded) { | ||
data = _this._showData(children, data); | ||
@@ -172,0 +177,0 @@ } |
@@ -67,2 +67,6 @@ 'use strict'; | ||
var _CacheManager = require('./managers/CacheManager'); | ||
var _CacheManager2 = _interopRequireDefault(_CacheManager); | ||
var _AutoSizer = require('./AutoSizer'); | ||
@@ -178,3 +182,3 @@ | ||
_this.sizeManager.update({ _scrollTop: target.scrollTop }); | ||
_this.resetShowData(target, true); | ||
_this.resetShowData(target); | ||
if (_this.props.refreshEnable) { | ||
@@ -203,4 +207,2 @@ _this.scrollRefresh(target); | ||
_this.resetShowData = function (target) { | ||
var isScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var scrollTop = 0; | ||
@@ -219,3 +221,2 @@ if (!target) { | ||
var state = {}; | ||
var needUpdate = true; | ||
if (!_this.sizeManager._hasScrollY) { | ||
@@ -225,39 +226,24 @@ state.startIndex = 0; | ||
} else { | ||
if (_this.lastIndex && isScroll) { | ||
var _this$lastIndex = _this.lastIndex, | ||
startIndex = _this$lastIndex.startIndex, | ||
stopIndex = _this$lastIndex.stopIndex; | ||
var start = dataSource[startIndex]; | ||
var end = dataSource[stopIndex]; | ||
if (!(scrollTop + target.clientHeight > end._top - 60 || scrollTop < start._top + 60)) { | ||
needUpdate = false; | ||
var startIndex = (0, _floor2.default)(scrollTop / rowHeight) - 1; | ||
for (var i = 0; i < dataSource.length; i++) { | ||
if (scrollTop < dataSource[i]._top) { | ||
startIndex = i - 1; | ||
break; | ||
} | ||
} | ||
if (needUpdate) { | ||
var _startIndex = (0, _floor2.default)(scrollTop / rowHeight) - 1; | ||
for (var i = 0; i < dataSource.length; i++) { | ||
if (scrollTop < dataSource[i]._top) { | ||
_startIndex = i - 1; | ||
break; | ||
} | ||
} | ||
var _stopIndex = _startIndex + _this.showCount; | ||
if (_this.lastScrollTop > scrollTop) { | ||
_startIndex -= 5; | ||
} else { | ||
_stopIndex += 5; | ||
} | ||
_startIndex = Math.max(0, _startIndex); | ||
_stopIndex = Math.min(_stopIndex, dataSource.length - 1); | ||
state.startIndex = _startIndex; | ||
state.stopIndex = _stopIndex; | ||
_this.lastIndex = state; | ||
var stopIndex = startIndex + _this.showCount; | ||
if (_this.lastScrollTop > scrollTop) { | ||
startIndex -= 5; | ||
} else { | ||
stopIndex += 5; | ||
} | ||
startIndex = Math.max(0, startIndex); | ||
stopIndex = Math.min(stopIndex, dataSource.length - 1); | ||
state.startIndex = startIndex; | ||
state.stopIndex = stopIndex; | ||
_this.lastIndex = state; | ||
} | ||
if (needUpdate) { | ||
for (var key in _this._forceTable) { | ||
if (_this._forceTable.hasOwnProperty(key) && _this._forceTable[key]) { | ||
_this._forceTable[key](state); | ||
} | ||
for (var key in _this._forceTable) { | ||
if (_this._forceTable.hasOwnProperty(key) && _this._forceTable[key]) { | ||
_this._forceTable[key](state); | ||
} | ||
@@ -271,2 +257,3 @@ } | ||
var dataManager = _this.dataManager; | ||
_this.cacheManager.resetCell(); | ||
var result = dataManager.expanded(record.key); | ||
@@ -404,2 +391,3 @@ if (typeof onExpandedRowsChange === 'function') { | ||
_this.sizeManager = new _SizeManager2.default(props); | ||
_this.cacheManager = new _CacheManager2.default(); | ||
@@ -428,2 +416,3 @@ _this.sizeManager.update(_extends({ | ||
sizeManager: this.sizeManager, | ||
cacheManager: this.cacheManager, | ||
components: (0, _merge2.default)({ | ||
@@ -467,2 +456,3 @@ table: 'div', | ||
}); | ||
this.cacheManager.resetCell(); | ||
this.getShowCount(); | ||
@@ -475,2 +465,3 @@ this.resetShowData(); | ||
this.store.setState({ orders: this.sortManager.enable }); | ||
this.cacheManager.resetCell(); | ||
this.updateColumn(); | ||
@@ -484,2 +475,3 @@ } | ||
}); | ||
this.cacheManager.resetCell(); | ||
this.getShowCount(); | ||
@@ -486,0 +478,0 @@ this.resetShowData(); |
@@ -15,9 +15,9 @@ 'use strict'; | ||
var _TableCell = require('./TableCell'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _TableCell2 = _interopRequireDefault(_TableCell); | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function Row(props) { | ||
var _classNames; | ||
function Row(props) { | ||
var key = props.key, | ||
@@ -27,17 +27,15 @@ className = props.className, | ||
prefixCls = props.prefixCls, | ||
columns = props.columns, | ||
onHover = props.onHover, | ||
onClick = props.onClick, | ||
expanded = props.expanded, | ||
fixed = props.fixed, | ||
indentSize = props.indentSize, | ||
components = props.components, | ||
renderExpandedIcon = props.renderExpandedIcon, | ||
expandedRowByClick = props.expandedRowByClick, | ||
hoverEnable = props.hoverEnable, | ||
handleExpanded = props.handleExpanded, | ||
scrollTop = props.scrollTop; | ||
scrollTop = props.scrollTop, | ||
hovered = props.hovered, | ||
hasExpanded = props.hasExpanded, | ||
cells = props.cells; | ||
var Tr = components.body.row; | ||
var rowClass = (0, _classnames2.default)('tr', prefixCls + '-row', prefixCls + '-row-' + record._showIndex % 2, className); | ||
var rowClass = (0, _classnames2.default)('tr', prefixCls + '-row', prefixCls + '-row-' + record._showIndex % 2, className, (_classNames = {}, _defineProperty(_classNames, prefixCls + '-hover', hovered), _defineProperty(_classNames, prefixCls + '-expanded-row-' + record._expandedLevel, hasExpanded), _defineProperty(_classNames, prefixCls + '-row-fixed', record._isFixed), _classNames)); | ||
var newProps = { | ||
@@ -77,23 +75,2 @@ key: key, | ||
} | ||
var cells = []; | ||
for (var i = 0; i < columns.length; i++) { | ||
var cellProps = { | ||
key: 'Row' + record._showIndex + '-Col' + i, | ||
column: columns[i], | ||
record: record, | ||
components: components | ||
}; | ||
if (renderExpandedIcon) { | ||
cellProps.ExpandedIcon = renderExpandedIcon({ | ||
columnIndex: i, | ||
record: record, | ||
prefixCls: prefixCls, | ||
fixed: fixed, | ||
expanded: expanded, | ||
indentSize: indentSize, | ||
handleExpanded: handleExpanded | ||
}); | ||
} | ||
cells.push((0, _TableCell2.default)(cellProps)); | ||
} | ||
return _react2.default.createElement( | ||
@@ -100,0 +77,0 @@ Tr, |
{ | ||
"name": "fast-table", | ||
"version": "1.3.13", | ||
"version": "1.4.0", | ||
"description": "react table fast", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
import TableHeader from './TableHeader'; | ||
import Row from './TableRow'; | ||
import { connect } from './mini-store'; | ||
import {connect} from './mini-store'; | ||
import renderExpandedIcon from './ExpandedIcon'; | ||
import Cell from './TableCell'; | ||
@@ -34,3 +34,3 @@ type Props = { | ||
componentDidMount() { | ||
const { registerForce, fixed } = this.props; | ||
const {registerForce, fixed} = this.props; | ||
if (registerForce) { | ||
@@ -52,6 +52,6 @@ registerForce(fixed, this.recomputeBody); | ||
handleSort = (key, order) => { | ||
const { sortManager, props } = this.context.table; | ||
const {sortManager, props} = this.context.table; | ||
const onSort = props.onSort; | ||
sortManager.setOrder(key, order, (orders) => { | ||
this.props.store.setState({ orders }); | ||
this.props.store.setState({orders}); | ||
if (typeof onSort === 'function') { | ||
@@ -63,3 +63,3 @@ onSort(orders); | ||
recomputeBody = ({ startIndex, stopIndex }) => { | ||
recomputeBody = ({startIndex, stopIndex}) => { | ||
this._startIndex = startIndex; | ||
@@ -85,5 +85,9 @@ this._stopIndex = stopIndex; | ||
} = table.props; | ||
const dataManager = table.dataManager; | ||
const sizeManager = table.sizeManager; | ||
const columns = table.columnManager.bodyColumns(fixed); | ||
const { | ||
dataManager, | ||
sizeManager, | ||
cacheManager, | ||
columnManager, | ||
} = table; | ||
const columns = columnManager.bodyColumns(fixed); | ||
const hasExpanded = dataManager._hasExpanded; | ||
@@ -93,2 +97,31 @@ const showData = dataManager.showData(); | ||
for (let record of dataSource) { | ||
const key = `Row${record._path}`; | ||
const cells = []; | ||
for (let i = 0; i < columns.length; i++) { | ||
const cellKey = `Row${record._path}-Col${i}_${fixed}`; | ||
let cell = cacheManager.getCell(cellKey); | ||
if (!cell || record._isFixed) { | ||
const cellProps = { | ||
key: cellKey, | ||
column: columns[i], | ||
record, | ||
components: table.components, | ||
}; | ||
if (hasExpanded) { | ||
cellProps.ExpandedIcon = renderExpandedIcon({ | ||
columnIndex: i, | ||
record, | ||
prefixCls, | ||
fixed, | ||
indentSize, | ||
handleExpanded: handleExpandChange, | ||
}); | ||
} | ||
cacheManager.setCell(cellKey, Cell(cellProps)); | ||
cell = cacheManager.getCell(cellKey); | ||
} | ||
cells.push(cell); | ||
} | ||
const className = typeof rowClassName === 'function' | ||
@@ -98,14 +131,8 @@ ? rowClassName(record, record._index) | ||
const props = { | ||
key: `Row${record._showIndex}`, | ||
className: classNames(className, { | ||
[`${prefixCls}-hover`]: currentHoverKey === record.key, | ||
[`${prefixCls}-expanded-row-${record._expandedLevel}`]: hasExpanded, | ||
[`${prefixCls}-row-fixed`]: record._isFixed, | ||
}), | ||
key, | ||
className, | ||
hasExpanded, | ||
record, | ||
prefixCls, | ||
columns, | ||
fixed, | ||
expandedRowByClick, | ||
expanded: dataManager.rowIsExpanded(record), | ||
onHover: this.handleRowHover, | ||
@@ -115,6 +142,6 @@ components: table.components, | ||
hoverEnable, | ||
indentSize, | ||
scrollTop: sizeManager._scrollTop, | ||
hovered: currentHoverKey === record.key, | ||
cells, | ||
}; | ||
hasExpanded && (props.renderExpandedIcon = renderExpandedIcon); | ||
rows.push(Row(props)); | ||
@@ -151,3 +178,3 @@ } | ||
body = ( | ||
<BodyWrapper className='tbody' style={{ height: sizeManager._dataHeight, minHeight: rowHeight }}> | ||
<BodyWrapper className='tbody' style={{height: sizeManager._dataHeight, minHeight: rowHeight}}> | ||
{this._children} | ||
@@ -159,3 +186,3 @@ </BodyWrapper> | ||
const width = columnManager.getWidth(fixed) || '100%'; | ||
const style = { width }; | ||
const style = {width}; | ||
if (!fixed) { | ||
@@ -162,0 +189,0 @@ style.minWidth = '100%'; |
@@ -6,3 +6,2 @@ import React from 'react'; | ||
prefixCls: string, | ||
expanded: boolean, | ||
record: Object, | ||
@@ -14,3 +13,2 @@ onClick: Function | ||
const { | ||
expanded, | ||
prefixCls, | ||
@@ -21,3 +19,3 @@ record, | ||
const newProps = { | ||
className: classNames(`${prefixCls}-expanded-icon`, {expanded}), | ||
className: classNames(`${prefixCls}-expanded-icon`, {expanded: record._expanded}), | ||
onClick: event => { | ||
@@ -38,3 +36,2 @@ event.stopPropagation(); | ||
fixed: string, | ||
expanded: boolean, | ||
indentSize: number, | ||
@@ -50,3 +47,2 @@ handleExpanded: Function | ||
fixed, | ||
expanded, | ||
indentSize, | ||
@@ -64,3 +60,2 @@ handleExpanded | ||
rowKey: record.key, | ||
expanded, | ||
onClick: handleExpanded | ||
@@ -67,0 +62,0 @@ }); |
@@ -111,7 +111,9 @@ import React from 'react'; | ||
_getData = (dataSource, level = 0) => { | ||
_getData = (dataSource, level = 0, parentPath) => { | ||
dataSource = dataSource || []; | ||
for (let index = 0; index < dataSource.length; index++) { | ||
const height = this.getRowHeight(dataSource[index], index) * this.rowHeight; | ||
const path = `${parentPath === undefined ? index : `${parentPath}-${index}`}`; | ||
dataSource[index]['_index'] = index; | ||
dataSource[index]['_path'] = path; | ||
dataSource[index]['_expandedLevel'] = level; | ||
@@ -127,3 +129,3 @@ dataSource[index]['_height'] = height; | ||
if (children.length > 0) { | ||
dataSource[index]['children'] = this._getData(children, level + 1); | ||
dataSource[index]['children'] = this._getData(children, level + 1, path); | ||
} | ||
@@ -153,4 +155,6 @@ } | ||
const children = record.children || []; | ||
const _expanded = expandedKeys.length > 0 && expandedKeys.indexOf(record.key) > -1 && children.length > 0; | ||
record._expanded = _expanded; | ||
data.push(record); | ||
if (expandedKeys.length > 0 && expandedKeys.indexOf(record.key) > -1 && children.length > 0) { | ||
if (_expanded) { | ||
data = this._showData(children, data); | ||
@@ -157,0 +161,0 @@ } |
@@ -16,2 +16,3 @@ import React from 'react'; | ||
import SizeManager from './managers/SizeManager'; | ||
import CacheManager from './managers/CacheManager'; | ||
import AutoSizer from './AutoSizer'; | ||
@@ -43,2 +44,3 @@ import {create, Provider} from './mini-store'; | ||
this.sizeManager = new SizeManager(props); | ||
this.cacheManager = new CacheManager(); | ||
@@ -70,2 +72,3 @@ this.sizeManager.update({ | ||
sizeManager: this.sizeManager, | ||
cacheManager: this.cacheManager, | ||
components: merge({ | ||
@@ -106,2 +109,3 @@ table: 'div', | ||
}); | ||
this.cacheManager.resetCell(); | ||
this.getShowCount(); | ||
@@ -114,2 +118,3 @@ this.resetShowData(); | ||
this.store.setState({orders: this.sortManager.enable}); | ||
this.cacheManager.resetCell(); | ||
this.updateColumn(); | ||
@@ -123,2 +128,3 @@ } | ||
}); | ||
this.cacheManager.resetCell(); | ||
this.getShowCount(); | ||
@@ -240,3 +246,3 @@ this.resetShowData(); | ||
this.sizeManager.update({_scrollTop: target.scrollTop}); | ||
this.resetShowData(target, true); | ||
this.resetShowData(target); | ||
if (this.props.refreshEnable) { | ||
@@ -261,3 +267,3 @@ this.scrollRefresh(target); | ||
resetShowData = (target, isScroll = false) => { | ||
resetShowData = (target) => { | ||
let scrollTop = 0; | ||
@@ -275,3 +281,2 @@ if (!target) { | ||
const state = {}; | ||
let needUpdate = true; | ||
if (!this.sizeManager._hasScrollY) { | ||
@@ -281,38 +286,24 @@ state.startIndex = 0; | ||
} else { | ||
if (this.lastIndex && isScroll) { | ||
const {startIndex, stopIndex} = this.lastIndex; | ||
const start = dataSource[startIndex]; | ||
const end = dataSource[stopIndex]; | ||
if (!(scrollTop + target.clientHeight > end._top - 60 || | ||
scrollTop < start._top + 60) | ||
) { | ||
needUpdate = false; | ||
let startIndex = floor(scrollTop / rowHeight) - 1; | ||
for (let i = 0; i < dataSource.length; i++) { | ||
if (scrollTop < dataSource[i]._top) { | ||
startIndex = i - 1; | ||
break; | ||
} | ||
} | ||
if (needUpdate) { | ||
let startIndex = floor(scrollTop / rowHeight) - 1; | ||
for (let i = 0; i < dataSource.length; i++) { | ||
if (scrollTop < dataSource[i]._top) { | ||
startIndex = i - 1; | ||
break; | ||
} | ||
} | ||
let stopIndex = startIndex + this.showCount; | ||
if (this.lastScrollTop > scrollTop) { | ||
startIndex -= 5; | ||
} else { | ||
stopIndex += 5; | ||
} | ||
startIndex = Math.max(0, startIndex); | ||
stopIndex = Math.min(stopIndex, dataSource.length - 1); | ||
state.startIndex = startIndex; | ||
state.stopIndex = stopIndex; | ||
this.lastIndex = state; | ||
let stopIndex = startIndex + this.showCount; | ||
if (this.lastScrollTop > scrollTop) { | ||
startIndex -= 5; | ||
} else { | ||
stopIndex += 5; | ||
} | ||
startIndex = Math.max(0, startIndex); | ||
stopIndex = Math.min(stopIndex, dataSource.length - 1); | ||
state.startIndex = startIndex; | ||
state.stopIndex = stopIndex; | ||
this.lastIndex = state; | ||
} | ||
if (needUpdate) { | ||
for (let key in this._forceTable) { | ||
if (this._forceTable.hasOwnProperty(key) && this._forceTable[key]) { | ||
this._forceTable[key](state); | ||
} | ||
for (let key in this._forceTable) { | ||
if (this._forceTable.hasOwnProperty(key) && this._forceTable[key]) { | ||
this._forceTable[key](state); | ||
} | ||
@@ -325,2 +316,3 @@ } | ||
const dataManager = this.dataManager; | ||
this.cacheManager.resetCell(); | ||
const result = dataManager.expanded(record.key); | ||
@@ -327,0 +319,0 @@ if (typeof onExpandedRowsChange === 'function') { |
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import Cell from './TableCell'; | ||
@@ -10,10 +9,5 @@ type Props = { | ||
prefixCls: string, | ||
columns: Array, | ||
onHover: Function, | ||
onClick: Function, | ||
expanded: boolean, | ||
fixed: string, | ||
indentSize: number, | ||
components: Object, | ||
renderExpandedIcon: Function, | ||
expandedRowByClick: boolean, | ||
@@ -23,2 +17,5 @@ hoverEnable: boolean, | ||
scrollTop: number, | ||
hovered: boolean, | ||
hasExpanded: boolean, | ||
cells: [React.Element<*>], | ||
} | ||
@@ -32,10 +29,5 @@ | ||
prefixCls, | ||
columns, | ||
onHover, | ||
onClick, | ||
expanded, | ||
fixed, | ||
indentSize, | ||
components, | ||
renderExpandedIcon, | ||
expandedRowByClick, | ||
@@ -45,2 +37,5 @@ hoverEnable, | ||
scrollTop, | ||
hovered, | ||
hasExpanded, | ||
cells, | ||
} = props; | ||
@@ -52,3 +47,8 @@ const Tr = components.body.row; | ||
`${prefixCls}-row-${record._showIndex % 2}`, | ||
className | ||
className, | ||
{ | ||
[`${prefixCls}-hover`]: hovered, | ||
[`${prefixCls}-expanded-row-${record._expandedLevel}`]: hasExpanded, | ||
[`${prefixCls}-row-fixed`]: record._isFixed, | ||
} | ||
); | ||
@@ -79,23 +79,2 @@ const newProps = { | ||
} | ||
const cells = []; | ||
for (let i = 0; i < columns.length; i++) { | ||
const cellProps = { | ||
key: `Row${record._showIndex}-Col${i}`, | ||
column: columns[i], | ||
record, | ||
components | ||
}; | ||
if (renderExpandedIcon) { | ||
cellProps.ExpandedIcon = renderExpandedIcon({ | ||
columnIndex: i, | ||
record, | ||
prefixCls, | ||
fixed, | ||
expanded, | ||
indentSize, | ||
handleExpanded | ||
}); | ||
} | ||
cells.push(Cell(cellProps)); | ||
} | ||
return ( | ||
@@ -102,0 +81,0 @@ <Tr {...newProps} > |
@@ -72,2 +72,1 @@ import React from 'react'; | ||
}; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176412
56
5044