UNPKG

33.1 kBJavaScriptView Raw
1import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
2import _typeof from 'babel-runtime/helpers/typeof';
3import _extends from 'babel-runtime/helpers/extends';
4import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
5import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
6import _inherits from 'babel-runtime/helpers/inherits';
7
8var _class, _temp;
9
10import React from 'react';
11import PropTypes from 'prop-types';
12import { findDOMNode } from 'react-dom';
13import classnames from 'classnames';
14import shallowElementEquals from 'shallow-element-equals';
15import { polyfill } from 'react-lifecycles-compat';
16import Loading from '../loading';
17import ConfigProvider from '../config-provider';
18import zhCN from '../locale/zh-cn';
19import { log, obj, dom } from '../util';
20import BodyComponent from './base/body';
21import HeaderComponent from './base/header';
22import WrapperComponent from './base/wrapper';
23import RowComponent from './base/row';
24import CellComponent from './base/cell';
25import FilterComponent from './base/filter';
26import SortComponent from './base/sort';
27import Column from './column';
28import ColumnGroup from './column-group';
29
30var Children = React.Children,
31 noop = function noop() {};
32
33//<Table>
34// <Table.Column/>
35// <Table.ColumnGroup>
36// <Table.Column/>
37// <Table.Column/>
38// </Table.ColumnGroup>
39//</Table>
40
41/** Table */
42var Table = (_temp = _class = function (_React$Component) {
43 _inherits(Table, _React$Component);
44
45 function Table(props, context) {
46 _classCallCheck(this, Table);
47
48 var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
49
50 _this.state = {
51 sort: _this.props.sort || {}
52 };
53
54 _this.onSort = function (dataIndex, order, sort) {
55 if (typeof _this.props.sort === 'undefined') {
56 _this.setState({
57 sort: sort
58 }, function () {
59 _this.props.onSort(dataIndex, order, sort);
60 });
61 } else {
62 _this.props.onSort(dataIndex, order, sort);
63 }
64 };
65
66 _this.onFilter = function (filterParams) {
67 _this.props.onFilter(filterParams);
68 };
69
70 _this.onResizeChange = function (dataIndex, value) {
71 _this.props.onResizeChange(dataIndex, value);
72 };
73
74 _this.getResizeProxyDomRef = function (resizeProxyDom) {
75 if (!resizeProxyDom) {
76 return _this.resizeProxyDomRef;
77 }
78 _this.resizeProxyDomRef = resizeProxyDom;
79 };
80
81 _this.getWrapperRef = function (wrapper) {
82 if (!wrapper) {
83 return _this.wrapper;
84 }
85 _this.wrapper = wrapper;
86 };
87
88 _this.getAffixRef = function (affixRef) {
89 if (!affixRef) {
90 return _this.affixRef;
91 }
92 _this.affixRef = affixRef;
93 };
94
95 _this.getHeaderCellRef = function (i, j, cell) {
96 var cellRef = 'header_cell_' + i + '_' + j;
97 if (!cell) {
98 return _this[cellRef];
99 }
100 _this[cellRef] = cell;
101 };
102
103 _this.getRowRef = function (i, row) {
104 var rowRef = 'row_' + i;
105 if (!row) {
106 return _this[rowRef];
107 }
108 _this[rowRef] = row;
109 };
110
111 _this.getCellRef = function (i, j, cell) {
112 var cellRef = 'cell_' + i + '_' + j;
113 if (!cell) {
114 return _this[cellRef];
115 }
116 _this[cellRef] = cell;
117 };
118
119 _this.handleColHoverClass = function (rowIndex, colIndex, isAdd) {
120 var crossline = _this.props.crossline;
121
122 var funcName = isAdd ? 'addClass' : 'removeClass';
123 if (crossline) {
124 _this.props.entireDataSource.forEach(function (val, index) {
125 try {
126 // in case of finding an unmounted component due to cached data
127 // need to clear refs of this.tableInc when dataSource Changed
128 // in virtual table
129 var currentCol = findDOMNode(_this.getCellRef(index, colIndex));
130 currentCol && dom[funcName](currentCol, 'hovered');
131 } catch (error) {
132 return null;
133 }
134 });
135 }
136 };
137
138 _this.findEventTarget = function (e) {
139 var prefix = _this.props.prefix;
140
141 var target = dom.getClosest(e.target, 'td.' + prefix + 'table-cell');
142 var colIndex = target && target.getAttribute('data-next-table-col');
143 var rowIndex = target && target.getAttribute('data-next-table-row');
144
145 try {
146 // in case of finding an unmounted component due to cached data
147 // need to clear refs of this.tableInc when dataSource Changed
148 // in virtual table
149 var currentCol = findDOMNode(_this.getCellRef(rowIndex, colIndex));
150 if (currentCol === target) {
151 return {
152 colIndex: colIndex,
153 rowIndex: rowIndex
154 };
155 }
156 } catch (error) {
157 return {};
158 }
159
160 return {};
161 };
162
163 _this.onBodyMouseOver = function (e) {
164 var crossline = _this.props.crossline;
165
166 if (!crossline) {
167 return;
168 }
169
170 var _this$findEventTarget = _this.findEventTarget(e),
171 colIndex = _this$findEventTarget.colIndex,
172 rowIndex = _this$findEventTarget.rowIndex;
173 // colIndex, rowIndex are string
174
175
176 if (!colIndex || !rowIndex) {
177 return;
178 }
179 _this.handleColHoverClass(rowIndex, colIndex, true);
180 _this.colIndex = colIndex;
181 _this.rowIndex = rowIndex;
182 };
183
184 _this.onBodyMouseOut = function (e) {
185 var crossline = _this.props.crossline;
186
187 if (!crossline) {
188 return;
189 }
190
191 var _this$findEventTarget2 = _this.findEventTarget(e),
192 colIndex = _this$findEventTarget2.colIndex,
193 rowIndex = _this$findEventTarget2.rowIndex;
194 // colIndex, rowIndex are string
195
196
197 if (!colIndex || !rowIndex) {
198 return;
199 }
200 _this.handleColHoverClass(_this.rowIndex, _this.colIndex, false);
201 _this.colIndex = -1;
202 _this.rowIndex = -1;
203 };
204
205 _this.addColIndex = function (children) {
206 var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
207
208 children.forEach(function (child, i) {
209 child.__colIndex = start + i;
210 });
211 };
212
213 _this.getTableEl = function (ref) {
214 _this.tableEl = ref;
215 };
216
217 var _this$context = _this.context,
218 getTableInstance = _this$context.getTableInstance,
219 getTableInstanceForVirtual = _this$context.getTableInstanceForVirtual,
220 getTableInstanceForFixed = _this$context.getTableInstanceForFixed,
221 getTableInstanceForExpand = _this$context.getTableInstanceForExpand;
222
223 getTableInstance && getTableInstance(props.lockType, _this);
224 getTableInstanceForFixed && getTableInstanceForFixed(props.lockType, _this);
225 getTableInstanceForVirtual && getTableInstanceForVirtual(props.lockType, _this);
226 getTableInstanceForExpand && getTableInstanceForExpand(_this);
227 _this.notRenderCellIndex = [];
228 return _this;
229 }
230
231 Table.prototype.getChildContext = function getChildContext() {
232 return {
233 notRenderCellIndex: this.notRenderCellIndex || [],
234 lockType: this.props.lockType
235 };
236 };
237
238 Table.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps) {
239 var state = {};
240
241 if (typeof nextProps.sort !== 'undefined') {
242 state.sort = nextProps.sort;
243 }
244
245 return state;
246 };
247
248 Table.prototype.componentDidMount = function componentDidMount() {
249 this.notRenderCellIndex = [];
250 };
251
252 Table.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState, nextContext) {
253 if (nextProps.pure) {
254 var isEqual = shallowElementEquals(nextProps, this.props) && obj.shallowEqual(nextState, this.state) && obj.shallowEqual(nextContext, this.context);
255 return !isEqual;
256 }
257
258 return true;
259 };
260
261 Table.prototype.componentDidUpdate = function componentDidUpdate() {
262 this.notRenderCellIndex = [];
263 };
264
265 Table.prototype.normalizeChildrenState = function normalizeChildrenState(props) {
266 var columns = props.columns;
267 if (props.children) {
268 columns = this.normalizeChildren(props);
269 }
270 return this.fetchInfoFromBinaryChildren(columns);
271 };
272
273 // 将React结构化数据提取props转换成数组
274
275
276 Table.prototype.normalizeChildren = function normalizeChildren(props) {
277 var columns = props.columns;
278
279 var getChildren = function getChildren(children) {
280 var ret = [];
281 Children.forEach(children, function (child) {
282 if (child) {
283 var _props = _extends({}, child.props);
284
285 if (child.ref) {
286 _props.ref = child.ref;
287 }
288
289 if (!(child && ['function', 'object'].indexOf(_typeof(child.type)) > -1 && (child.type._typeMark === 'column' || child.type._typeMark === 'columnGroup'))) {
290 log.warning('Use <Table.Column/>, <Table.ColumnGroup/> as child.');
291 }
292 ret.push(_props);
293 if (child.props.children) {
294 _props.children = getChildren(child.props.children);
295 }
296 }
297 });
298 return ret;
299 };
300 if (props.children) {
301 columns = getChildren(props.children);
302 }
303 return columns;
304 };
305
306 Table.prototype.fetchInfoFromBinaryChildren = function fetchInfoFromBinaryChildren(children) {
307 var hasGroupHeader = false;
308 var flatChildren = [],
309 groupChildren = [],
310 getChildren = function getChildren() {
311 var propsChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
312 var level = arguments[1];
313
314 groupChildren[level] = groupChildren[level] || [];
315 propsChildren.forEach(function (child) {
316 if (child.children) {
317 hasGroupHeader = true;
318 getChildren(child.children, level + 1);
319 } else {
320 flatChildren.push(child);
321 }
322 groupChildren[level].push(child);
323 });
324 },
325 getColSpan = function getColSpan(children, colSpan) {
326 colSpan = colSpan || 0;
327 children.forEach(function (child) {
328 if (child.children) {
329 colSpan = getColSpan(child.children, colSpan);
330 } else {
331 colSpan += 1;
332 }
333 });
334 return colSpan;
335 };
336
337 getChildren(children, 0);
338
339 groupChildren.forEach(function (groupChild, i) {
340 groupChild.forEach(function (child, j) {
341 var colSpan = void 0;
342 var children = child.children;
343
344 if (children) {
345 colSpan = getColSpan(children);
346 child.colSpan = colSpan;
347 groupChildren[i][j] = child;
348 }
349 });
350 });
351
352 var _props2 = this.props,
353 lockType = _props2.lockType,
354 lengths = _props2.lengths;
355
356 var start = lockType === 'right' ? lengths.origin - lengths.right : 0;
357 this.addColIndex(flatChildren, start);
358
359 return {
360 flatChildren: flatChildren,
361 groupChildren: groupChildren,
362 hasGroupHeader: hasGroupHeader
363 };
364 };
365
366 Table.prototype.renderColGroup = function renderColGroup(flatChildren) {
367 var cols = flatChildren.map(function (col, index) {
368 var width = col.width;
369 var style = {};
370 if (width) {
371 style = {
372 width: width
373 };
374 }
375
376 return React.createElement('col', { style: style, key: index });
377 });
378 return React.createElement(
379 'colgroup',
380 { key: 'table-colgroup' },
381 cols
382 );
383 };
384
385 // 通过头部和扁平的结构渲染表格
386 Table.prototype.renderTable = function renderTable(groupChildren, flatChildren) {
387 if (flatChildren.length || !flatChildren.length && !this.props.lockType) {
388 var _props3 = this.props,
389 hasHeader = _props3.hasHeader,
390 components = _props3.components,
391 prefix = _props3.prefix,
392 wrapperContent = _props3.wrapperContent,
393 filterParams = _props3.filterParams,
394 locale = _props3.locale,
395 dataSource = _props3.dataSource,
396 emptyContent = _props3.emptyContent,
397 loading = _props3.loading,
398 primaryKey = _props3.primaryKey,
399 cellProps = _props3.cellProps,
400 rowProps = _props3.rowProps,
401 onRowClick = _props3.onRowClick,
402 onRowMouseEnter = _props3.onRowMouseEnter,
403 onRowMouseLeave = _props3.onRowMouseLeave,
404 expandedIndexSimulate = _props3.expandedIndexSimulate,
405 pure = _props3.pure,
406 rtl = _props3.rtl,
407 crossline = _props3.crossline,
408 sortIcons = _props3.sortIcons,
409 tableWidth = _props3.tableWidth;
410 var sort = this.state.sort;
411 var _components$Header = components.Header,
412 Header = _components$Header === undefined ? HeaderComponent : _components$Header,
413 _components$Wrapper = components.Wrapper,
414 Wrapper = _components$Wrapper === undefined ? WrapperComponent : _components$Wrapper,
415 _components$Body = components.Body,
416 Body = _components$Body === undefined ? BodyComponent : _components$Body;
417
418 var colGroup = this.renderColGroup(flatChildren);
419
420 return [React.createElement('div', {
421 key: prefix + 'table-column-resize-proxy',
422 ref: this.getResizeProxyDomRef,
423 className: prefix + 'table-column-resize-proxy'
424 }), React.createElement(
425 Wrapper,
426 {
427 key: prefix + 'table-wrapper',
428 colGroup: colGroup,
429 ref: this.getWrapperRef,
430 prefix: prefix,
431 tableWidth: tableWidth
432 },
433 hasHeader ? React.createElement(Header, {
434 prefix: prefix,
435 rtl: rtl,
436 pure: pure,
437 affixRef: this.getAffixRef,
438 colGroup: colGroup,
439 className: prefix + 'table-header',
440 filterParams: filterParams,
441 tableEl: this.tableEl,
442 columns: groupChildren,
443 locale: locale,
444 headerCellRef: this.getHeaderCellRef,
445 components: components,
446 onFilter: this.onFilter,
447 sort: sort,
448 onResizeChange: this.onResizeChange,
449 onSort: this.onSort,
450 sortIcons: sortIcons,
451 tableWidth: tableWidth,
452 resizeProxyDomRef: this.resizeProxyDomRef
453 }) : null,
454 React.createElement(Body, {
455 prefix: prefix,
456 rtl: rtl,
457 pure: pure,
458 crossline: crossline,
459 colGroup: colGroup,
460 className: prefix + 'table-body',
461 components: components,
462 loading: loading,
463 emptyContent: emptyContent,
464 getCellProps: cellProps,
465 primaryKey: primaryKey,
466 getRowProps: rowProps,
467 columns: flatChildren,
468 rowRef: this.getRowRef,
469 cellRef: this.getCellRef,
470 onRowClick: onRowClick,
471 expandedIndexSimulate: expandedIndexSimulate,
472 tableEl: this.tableEl,
473 onRowMouseEnter: onRowMouseEnter,
474 onRowMouseLeave: onRowMouseLeave,
475 dataSource: dataSource,
476 locale: locale,
477 onBodyMouseOver: this.onBodyMouseOver,
478 onBodyMouseOut: this.onBodyMouseOut,
479 tableWidth: tableWidth
480 }),
481 wrapperContent
482 )];
483 } else {
484 return null;
485 }
486 };
487
488 /**
489 * @param event
490 * @returns {Object} { rowIndex: string; colIndex: string }
491 */
492
493
494 Table.prototype.render = function render() {
495 var _classnames;
496
497 var ret = this.normalizeChildrenState(this.props);
498 this.groupChildren = ret.groupChildren;
499 this.flatChildren = ret.flatChildren;
500 /* eslint-disable no-unused-vars, prefer-const */
501 var table = this.renderTable(ret.groupChildren, ret.flatChildren),
502 _props4 = this.props,
503 className = _props4.className,
504 style = _props4.style,
505 hasBorder = _props4.hasBorder,
506 isZebra = _props4.isZebra,
507 loading = _props4.loading,
508 size = _props4.size,
509 hasHeader = _props4.hasHeader,
510 prefix = _props4.prefix,
511 dataSource = _props4.dataSource,
512 entireDataSource = _props4.entireDataSource,
513 onSort = _props4.onSort,
514 onResizeChange = _props4.onResizeChange,
515 onRowClick = _props4.onRowClick,
516 onRowMouseEnter = _props4.onRowMouseEnter,
517 onRowMouseLeave = _props4.onRowMouseLeave,
518 onFilter = _props4.onFilter,
519 rowProps = _props4.rowProps,
520 cellProps = _props4.cellProps,
521 scrollToRow = _props4.scrollToRow,
522 primaryKey = _props4.primaryKey,
523 components = _props4.components,
524 wrapperContent = _props4.wrapperContent,
525 lockType = _props4.lockType,
526 locale = _props4.locale,
527 expandedIndexSimulate = _props4.expandedIndexSimulate,
528 refs = _props4.refs,
529 pure = _props4.pure,
530 rtl = _props4.rtl,
531 emptyContent = _props4.emptyContent,
532 filterParams = _props4.filterParams,
533 columns = _props4.columns,
534 sortIcons = _props4.sortIcons,
535 _props4$loadingCompon = _props4.loadingComponent,
536 LoadingComponent = _props4$loadingCompon === undefined ? Loading : _props4$loadingCompon,
537 tableLayout = _props4.tableLayout,
538 tableWidth = _props4.tableWidth,
539 ref = _props4.ref,
540 others = _objectWithoutProperties(_props4, ['className', 'style', 'hasBorder', 'isZebra', 'loading', 'size', 'hasHeader', 'prefix', 'dataSource', 'entireDataSource', 'onSort', 'onResizeChange', 'onRowClick', 'onRowMouseEnter', 'onRowMouseLeave', 'onFilter', 'rowProps', 'cellProps', 'scrollToRow', 'primaryKey', 'components', 'wrapperContent', 'lockType', 'locale', 'expandedIndexSimulate', 'refs', 'pure', 'rtl', 'emptyContent', 'filterParams', 'columns', 'sortIcons', 'loadingComponent', 'tableLayout', 'tableWidth', 'ref']),
541 cls = classnames((_classnames = {}, _classnames[prefix + 'table'] = true, _classnames[prefix + 'table-' + size] = size, _classnames[prefix + 'table-layout-' + tableLayout] = tableLayout, _classnames['only-bottom-border'] = !hasBorder, _classnames['no-header'] = !hasHeader, _classnames.zebra = isZebra, _classnames[className] = className, _classnames));
542
543
544 if (rtl) {
545 others.dir = 'rtl';
546 }
547
548 var content = React.createElement(
549 'div',
550 _extends({
551 className: cls,
552 style: style,
553 ref: ref || this.getTableEl
554 }, obj.pickOthers(Object.keys(Table.propTypes), others)),
555 table
556 );
557 if (loading) {
558 var loadingClassName = prefix + 'table-loading';
559 return React.createElement(
560 LoadingComponent,
561 { className: loadingClassName },
562 content
563 );
564 }
565 return content;
566 };
567
568 return Table;
569}(React.Component), _class.Column = Column, _class.ColumnGroup = ColumnGroup, _class.Header = HeaderComponent, _class.Body = BodyComponent, _class.Wrapper = WrapperComponent, _class.Row = RowComponent, _class.Cell = CellComponent, _class.Filter = FilterComponent, _class.Sort = SortComponent, _class.propTypes = _extends({}, ConfigProvider.propTypes, {
570 /**
571 * 样式类名的品牌前缀
572 */
573 prefix: PropTypes.string,
574 pure: PropTypes.bool,
575 rtl: PropTypes.bool,
576 /**
577 * 表格元素的 table-layout 属性,设为 fixed 表示内容不会影响列的布局
578 */
579 tableLayout: PropTypes.oneOf(['fixed', 'auto']),
580 /**
581 * 表格的总长度,可以这么用:设置表格总长度 、设置部分列的宽度,这样表格会按照剩余空间大小,自动其他列分配宽度
582 */
583 tableWidth: PropTypes.number,
584 /**
585 * 自定义类名
586 */
587 className: PropTypes.string,
588 /**
589 * 自定义内联样式
590 */
591 style: PropTypes.object,
592 /**
593 * 尺寸 small为紧凑模式
594 */
595 size: PropTypes.oneOf(['small', 'medium']),
596 /**
597 * 表格展示的数据源
598 */
599 dataSource: PropTypes.array,
600 entireDataSource: PropTypes.array,
601 /**
602 * 点击表格每一行触发的事件
603 * @param {Object} record 该行所对应的数据
604 * @param {Number} index 该行所对应的序列
605 * @param {Event} e DOM事件对象
606 */
607 onRowClick: PropTypes.func,
608 /**
609 * 悬浮在表格每一行的时候触发的事件
610 * @param {Object} record 该行所对应的数据
611 * @param {Number} index 该行所对应的序列
612 * @param {Event} e DOM事件对象
613 */
614 onRowMouseEnter: PropTypes.func,
615 /**
616 * 离开表格每一行的时候触发的事件
617 * @param {Object} record 该行所对应的数据
618 * @param {Number} index 该行所对应的序列
619 * @param {Event} e DOM事件对象
620 */
621 onRowMouseLeave: PropTypes.func,
622 /**
623 * 点击列排序触发的事件
624 * @param {String} dataIndex 指定的排序的字段
625 * @param {String} order 排序对应的顺序, 有`desc`和`asc`两种
626 */
627 onSort: PropTypes.func,
628 /**
629 * 点击过滤确认按钮触发的事件
630 * @param {Object} filterParams 过滤的字段信息
631 */
632 onFilter: PropTypes.func,
633 /**
634 * 重设列尺寸的时候触发的事件
635 * @param {String} dataIndex 指定重设的字段
636 * @param {Number} value 列宽变动的数值
637 */
638 onResizeChange: PropTypes.func,
639 /**
640 * 设置每一行的属性,如果返回值和其他针对行操作的属性冲突则无效。
641 * @param {Object} record 该行所对应的数据
642 * @param {Number} index 该行所对应的序列
643 * @returns {Object} 需要设置的行属性
644 */
645 rowProps: PropTypes.func,
646 /**
647 * 设置单元格的属性,通过该属性可以进行合并单元格
648 * @param {Number} rowIndex 该行所对应的序列
649 * @param {Number} colIndex 该列所对应的序列
650 * @param {String} dataIndex 该列所对应的字段名称
651 * @param {Object} record 该行对应的记录
652 * @returns {Object} 返回td元素的所支持的属性对象
653 */
654 cellProps: PropTypes.func,
655 /**
656 * 表格是否具有边框
657 */
658 hasBorder: PropTypes.bool,
659 /**
660 * 表格是否具有头部
661 */
662 hasHeader: PropTypes.bool,
663 /**
664 * 表格是否是斑马线
665 */
666 isZebra: PropTypes.bool,
667 /**
668 * 表格是否在加载中
669 */
670 loading: PropTypes.bool,
671 /**
672 * 自定义 Loading 组件
673 * 请务必传递 props, 使用方式: loadingComponent={props => <Loading {...props}/>}
674 * @param {LoadingProps} props 需要透传给组件的参数
675 * @return {React.ReactNode} 展示的组件
676 */
677 loadingComponent: PropTypes.func,
678 /**
679 * 当前过滤的的keys,使用此属性可以控制表格的头部的过滤选项中哪个菜单被选中,格式为 {dataIndex: {selectedKeys:[]}}
680 * 示例:
681 * 假设要控制dataIndex为id的列的过滤菜单中key为one的菜单项选中
682 * `<Table filterParams={{id: {selectedKeys: ['one']}}}/>`
683 */
684 filterParams: PropTypes.object,
685 /**
686 * 当前排序的字段,使用此属性可以控制表格的字段的排序,格式为{[dataIndex]: 'asc' | 'desc' } , 例如 {id: 'desc'}
687 */
688 sort: PropTypes.object,
689 /**
690 * 自定义排序按钮,例如上下排布的: `{desc: <Icon style={{top: '6px', left: '4px'}} type={'arrow-down'} size="small" />, asc: <Icon style={{top: '-6px', left: '4px'}} type={'arrow-up'} size="small" />}`
691 */
692 sortIcons: PropTypes.object,
693 /**
694 * 自定义国际化文案对象
695 * @property {String} ok 过滤器中确认按钮文案
696 * @property {String} reset 过滤器中重置按钮文案
697 * @property {String} empty 没有数据情况下 table内的文案
698 * @property {String} asc 排序升序状态下的文案
699 * @property {String} desc 排序将序状态下的文案
700 * @property {String} expanded 可折叠行,展开状态下的文案
701 * @property {String} folded 可折叠行,折叠状态下的文案
702 * @property {String} filter 过滤器文案
703 * @property {String} selectAll header里全选的按钮文案
704 */
705 locale: PropTypes.object,
706 components: PropTypes.object,
707 /**
708 * 等同于写子组件 Table.Column ,子组件优先级更高
709 */
710 columns: PropTypes.array,
711 /**
712 * 设置数据为空的时候的表格内容展现
713 */
714 emptyContent: PropTypes.node,
715 /**
716 * dataSource当中数据的主键,如果给定的数据源中的属性不包含该主键,会造成选择状态全部选中
717 */
718 primaryKey: PropTypes.oneOfType([PropTypes.symbol, PropTypes.string]),
719 lockType: PropTypes.oneOf(['left', 'right']),
720 wrapperContent: PropTypes.any,
721 refs: PropTypes.object,
722 /**
723 * 额外渲染行的渲染函数
724 * @param {Object} record 该行所对应的数据
725 * @param {Number} index 该行所对应的序列
726 * @returns {Element} 渲染内容
727 */
728 expandedRowRender: PropTypes.func,
729 /**
730 * 设置行是否可展开,设置 false 为不可展开
731 * @param {Object} record 该行所对应的数据
732 * @param {Number} index 该行所对应的序列
733 * @returns {Boolean} 是否可展开
734 */
735 rowExpandable: PropTypes.func,
736 /**
737 * 额外渲染行的缩进
738 */
739 expandedRowIndent: PropTypes.array,
740 /**
741 * 是否显示点击展开额外渲染行的+号按钮
742 */
743 hasExpandedRowCtrl: PropTypes.bool,
744 /**
745 * 设置额外渲染行的属性
746 * @param {Object} record 该行所对应的数据
747 * @param {Number} index 该行所对应的序列
748 * @returns {Object} 额外渲染行的属性
749 */
750 getExpandedColProps: PropTypes.func,
751 /**
752 * 当前展开的 Expand行 或者 Tree行 , 传入此属性为受控状态,一般配合 onRowOpen 使用
753 */
754 openRowKeys: PropTypes.array,
755 /**
756 * 默认情况下展开的 Expand行 或者 Tree行,非受控模式
757 * @version 1.23.22
758 */
759 defaultOpenRowKeys: PropTypes.array,
760 /**
761 * 在 Expand行 或者 Tree行 展开或者收起的时候触发的事件
762 * @param {Array} openRowKeys 展开的渲染行的key
763 * @param {String} currentRowKey 当前点击的渲染行的key
764 * @param {Boolean} expanded 当前点击是展开还是收起
765 * @param {Object} currentRecord 当前点击额外渲染行的记录
766 */
767 onRowOpen: PropTypes.func,
768 onExpandedRowClick: PropTypes.func,
769 /**
770 * 表头是否固定,该属性配合maxBodyHeight使用,当内容区域的高度超过maxBodyHeight的时候,在内容区域会出现滚动条
771 */
772 fixedHeader: PropTypes.bool,
773 /**
774 * 最大内容区域的高度,在`fixedHeader`为`true`的时候,超过这个高度会出现滚动条
775 */
776 maxBodyHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
777 /**
778 * 是否启用选择模式
779 * @property {Function} getProps `Function(record, index)=>Object` 获取selection的默认属性
780 * @property {Function} onChange `Function(selectedRowKeys:Array, records:Array)` 选择改变的时候触发的事件,**注意:** 其中records只会包含当前dataSource的数据,很可能会小于selectedRowKeys的长度。
781 * @property {Function} onSelect `Function(selected:Boolean, record:Object, records:Array)` 用户手动选择/取消选择某行的回调
782 * @property {Function} onSelectAll `Function(selected:Boolean, records:Array)` 用户手动选择/取消选择所有行的回调
783 * @property {Array} selectedRowKeys 设置了此属性,将rowSelection变为受控状态,接收值为该行数据的primaryKey的值
784 * @property {String} mode 选择selection的模式, 可选值为`single`, `multiple`,默认为`multiple`
785 * @property {Function} columnProps `Function()=>Object` 选择列 的props,例如锁列、对齐等,可使用`Table.Column` 的所有参数
786 * @property {Function} titleProps `Function()=>Object` 选择列 表头的props,仅在 `multiple` 模式下生效
787 * @property {Function} titleAddons `Function()=>Node` 选择列 表头添加的元素,在`single` `multiple` 下都生效
788 */
789 rowSelection: PropTypes.object,
790 /**
791 * 表头是否是sticky
792 */
793 stickyHeader: PropTypes.bool,
794 /**
795 * 距离窗口顶部达到指定偏移量后触发
796 */
797 offsetTop: PropTypes.number,
798 /**
799 * affix组件的的属性
800 */
801 affixProps: PropTypes.object,
802 /**
803 * 在tree模式下的缩进尺寸, 仅在isTree为true时候有效
804 */
805 indent: PropTypes.number,
806 /**
807 * 开启Table的tree模式, 接收的数据格式中包含children则渲染成tree table
808 */
809 isTree: PropTypes.bool,
810 /**
811 * 是否开启虚拟滚动
812 */
813 useVirtual: PropTypes.bool,
814 rowHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
815 /**
816 * 滚动到第几行,需要保证行高相同。1.22.15 版本之前仅在虚拟滚动场景下生效,之后在所有情况下生效
817 * @version 1.22.15
818 */
819 scrollToRow: PropTypes.number,
820 /**
821 * 在内容区域滚动的时候触发的函数
822 */
823 onBodyScroll: PropTypes.func,
824 /**
825 * 开启时,getExpandedColProps() / rowProps() / expandedRowRender() 的第二个参数 index (该行所对应的序列) 将按照01,2,3,4...的顺序返回,否则返回真实index(0,2,4,6... / 1,3,5,7...)
826 */
827 expandedIndexSimulate: PropTypes.bool,
828 /**
829 * 在 hover 时出现十字参考轴,适用于表头比较复杂,需要做表头分类的场景。
830 */
831 crossline: PropTypes.bool,
832 lengths: PropTypes.object
833}), _class.defaultProps = {
834 dataSource: [],
835 onRowClick: noop,
836 onRowMouseEnter: noop,
837 onRowMouseLeave: noop,
838 onSort: noop,
839 onFilter: noop,
840 onResizeChange: noop,
841 size: 'medium',
842 rowProps: noop,
843 cellProps: noop,
844 prefix: 'next-',
845 hasBorder: true,
846 hasHeader: true,
847 isZebra: false,
848 loading: false,
849 expandedIndexSimulate: false,
850 primaryKey: 'id',
851 components: {},
852 locale: zhCN.Table,
853 crossline: false
854}, _class.childContextTypes = {
855 notRenderCellIndex: PropTypes.array,
856 lockType: PropTypes.oneOf(['left', 'right'])
857}, _class.contextTypes = {
858 getTableInstance: PropTypes.func,
859 getTableInstanceForFixed: PropTypes.func,
860 getTableInstanceForVirtual: PropTypes.func,
861 getTableInstanceForExpand: PropTypes.func
862}, _temp);
863Table.displayName = 'Table';
864
865
866export default polyfill(Table);
\No newline at end of file