1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 |
|
5 | var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
|
6 |
|
7 | var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
|
8 |
|
9 | var _typeof2 = require('babel-runtime/helpers/typeof');
|
10 |
|
11 | var _typeof3 = _interopRequireDefault(_typeof2);
|
12 |
|
13 | var _extends2 = require('babel-runtime/helpers/extends');
|
14 |
|
15 | var _extends3 = _interopRequireDefault(_extends2);
|
16 |
|
17 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
18 |
|
19 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
20 |
|
21 | var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
22 |
|
23 | var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
24 |
|
25 | var _inherits2 = require('babel-runtime/helpers/inherits');
|
26 |
|
27 | var _inherits3 = _interopRequireDefault(_inherits2);
|
28 |
|
29 | var _class, _temp;
|
30 |
|
31 | var _react = require('react');
|
32 |
|
33 | var _react2 = _interopRequireDefault(_react);
|
34 |
|
35 | var _propTypes = require('prop-types');
|
36 |
|
37 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
38 |
|
39 | var _reactDom = require('react-dom');
|
40 |
|
41 | var _classnames2 = require('classnames');
|
42 |
|
43 | var _classnames3 = _interopRequireDefault(_classnames2);
|
44 |
|
45 | var _shallowElementEquals = require('shallow-element-equals');
|
46 |
|
47 | var _shallowElementEquals2 = _interopRequireDefault(_shallowElementEquals);
|
48 |
|
49 | var _reactLifecyclesCompat = require('react-lifecycles-compat');
|
50 |
|
51 | var _loading = require('../loading');
|
52 |
|
53 | var _loading2 = _interopRequireDefault(_loading);
|
54 |
|
55 | var _configProvider = require('../config-provider');
|
56 |
|
57 | var _configProvider2 = _interopRequireDefault(_configProvider);
|
58 |
|
59 | var _zhCn = require('../locale/zh-cn');
|
60 |
|
61 | var _zhCn2 = _interopRequireDefault(_zhCn);
|
62 |
|
63 | var _util = require('../util');
|
64 |
|
65 | var _body = require('./base/body');
|
66 |
|
67 | var _body2 = _interopRequireDefault(_body);
|
68 |
|
69 | var _header = require('./base/header');
|
70 |
|
71 | var _header2 = _interopRequireDefault(_header);
|
72 |
|
73 | var _wrapper = require('./base/wrapper');
|
74 |
|
75 | var _wrapper2 = _interopRequireDefault(_wrapper);
|
76 |
|
77 | var _row = require('./base/row');
|
78 |
|
79 | var _row2 = _interopRequireDefault(_row);
|
80 |
|
81 | var _cell = require('./base/cell');
|
82 |
|
83 | var _cell2 = _interopRequireDefault(_cell);
|
84 |
|
85 | var _filter = require('./base/filter');
|
86 |
|
87 | var _filter2 = _interopRequireDefault(_filter);
|
88 |
|
89 | var _sort = require('./base/sort');
|
90 |
|
91 | var _sort2 = _interopRequireDefault(_sort);
|
92 |
|
93 | var _column = require('./column');
|
94 |
|
95 | var _column2 = _interopRequireDefault(_column);
|
96 |
|
97 | var _columnGroup = require('./column-group');
|
98 |
|
99 | var _columnGroup2 = _interopRequireDefault(_columnGroup);
|
100 |
|
101 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
102 |
|
103 | var Children = _react2.default.Children,
|
104 | noop = function noop() {};
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | var Table = (_temp = _class = function (_React$Component) {
|
116 | (0, _inherits3.default)(Table, _React$Component);
|
117 |
|
118 | function Table(props, context) {
|
119 | (0, _classCallCheck3.default)(this, Table);
|
120 |
|
121 | var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props, context));
|
122 |
|
123 | _this.state = {
|
124 | sort: _this.props.sort || {}
|
125 | };
|
126 |
|
127 | _this.onSort = function (dataIndex, order, sort) {
|
128 | if (typeof _this.props.sort === 'undefined') {
|
129 | _this.setState({
|
130 | sort: sort
|
131 | }, function () {
|
132 | _this.props.onSort(dataIndex, order, sort);
|
133 | });
|
134 | } else {
|
135 | _this.props.onSort(dataIndex, order, sort);
|
136 | }
|
137 | };
|
138 |
|
139 | _this.onFilter = function (filterParams) {
|
140 | _this.props.onFilter(filterParams);
|
141 | };
|
142 |
|
143 | _this.onResizeChange = function (dataIndex, value) {
|
144 | _this.props.onResizeChange(dataIndex, value);
|
145 | };
|
146 |
|
147 | _this.getResizeProxyDomRef = function (resizeProxyDom) {
|
148 | if (!resizeProxyDom) {
|
149 | return _this.resizeProxyDomRef;
|
150 | }
|
151 | _this.resizeProxyDomRef = resizeProxyDom;
|
152 | };
|
153 |
|
154 | _this.getWrapperRef = function (wrapper) {
|
155 | if (!wrapper) {
|
156 | return _this.wrapper;
|
157 | }
|
158 | _this.wrapper = wrapper;
|
159 | };
|
160 |
|
161 | _this.getAffixRef = function (affixRef) {
|
162 | if (!affixRef) {
|
163 | return _this.affixRef;
|
164 | }
|
165 | _this.affixRef = affixRef;
|
166 | };
|
167 |
|
168 | _this.getHeaderCellRef = function (i, j, cell) {
|
169 | var cellRef = 'header_cell_' + i + '_' + j;
|
170 | if (!cell) {
|
171 | return _this[cellRef];
|
172 | }
|
173 | _this[cellRef] = cell;
|
174 | };
|
175 |
|
176 | _this.getRowRef = function (i, row) {
|
177 | var rowRef = 'row_' + i;
|
178 | if (!row) {
|
179 | return _this[rowRef];
|
180 | }
|
181 | _this[rowRef] = row;
|
182 | };
|
183 |
|
184 | _this.getCellRef = function (i, j, cell) {
|
185 | var cellRef = 'cell_' + i + '_' + j;
|
186 | if (!cell) {
|
187 | return _this[cellRef];
|
188 | }
|
189 | _this[cellRef] = cell;
|
190 | };
|
191 |
|
192 | _this.handleColHoverClass = function (rowIndex, colIndex, isAdd) {
|
193 | var crossline = _this.props.crossline;
|
194 |
|
195 | var funcName = isAdd ? 'addClass' : 'removeClass';
|
196 | if (crossline) {
|
197 | _this.props.entireDataSource.forEach(function (val, index) {
|
198 | try {
|
199 |
|
200 |
|
201 |
|
202 | var currentCol = (0, _reactDom.findDOMNode)(_this.getCellRef(index, colIndex));
|
203 | currentCol && _util.dom[funcName](currentCol, 'hovered');
|
204 | } catch (error) {
|
205 | return null;
|
206 | }
|
207 | });
|
208 | }
|
209 | };
|
210 |
|
211 | _this.findEventTarget = function (e) {
|
212 | var prefix = _this.props.prefix;
|
213 |
|
214 | var target = _util.dom.getClosest(e.target, 'td.' + prefix + 'table-cell');
|
215 | var colIndex = target && target.getAttribute('data-next-table-col');
|
216 | var rowIndex = target && target.getAttribute('data-next-table-row');
|
217 |
|
218 | try {
|
219 |
|
220 |
|
221 |
|
222 | var currentCol = (0, _reactDom.findDOMNode)(_this.getCellRef(rowIndex, colIndex));
|
223 | if (currentCol === target) {
|
224 | return {
|
225 | colIndex: colIndex,
|
226 | rowIndex: rowIndex
|
227 | };
|
228 | }
|
229 | } catch (error) {
|
230 | return {};
|
231 | }
|
232 |
|
233 | return {};
|
234 | };
|
235 |
|
236 | _this.onBodyMouseOver = function (e) {
|
237 | var crossline = _this.props.crossline;
|
238 |
|
239 | if (!crossline) {
|
240 | return;
|
241 | }
|
242 |
|
243 | var _this$findEventTarget = _this.findEventTarget(e),
|
244 | colIndex = _this$findEventTarget.colIndex,
|
245 | rowIndex = _this$findEventTarget.rowIndex;
|
246 |
|
247 |
|
248 |
|
249 | if (!colIndex || !rowIndex) {
|
250 | return;
|
251 | }
|
252 | _this.handleColHoverClass(rowIndex, colIndex, true);
|
253 | _this.colIndex = colIndex;
|
254 | _this.rowIndex = rowIndex;
|
255 | };
|
256 |
|
257 | _this.onBodyMouseOut = function (e) {
|
258 | var crossline = _this.props.crossline;
|
259 |
|
260 | if (!crossline) {
|
261 | return;
|
262 | }
|
263 |
|
264 | var _this$findEventTarget2 = _this.findEventTarget(e),
|
265 | colIndex = _this$findEventTarget2.colIndex,
|
266 | rowIndex = _this$findEventTarget2.rowIndex;
|
267 |
|
268 |
|
269 |
|
270 | if (!colIndex || !rowIndex) {
|
271 | return;
|
272 | }
|
273 | _this.handleColHoverClass(_this.rowIndex, _this.colIndex, false);
|
274 | _this.colIndex = -1;
|
275 | _this.rowIndex = -1;
|
276 | };
|
277 |
|
278 | _this.addColIndex = function (children) {
|
279 | var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
280 |
|
281 | children.forEach(function (child, i) {
|
282 | child.__colIndex = start + i;
|
283 | });
|
284 | };
|
285 |
|
286 | _this.getTableEl = function (ref) {
|
287 | _this.tableEl = ref;
|
288 | };
|
289 |
|
290 | var _this$context = _this.context,
|
291 | getTableInstance = _this$context.getTableInstance,
|
292 | getTableInstanceForVirtual = _this$context.getTableInstanceForVirtual,
|
293 | getTableInstanceForFixed = _this$context.getTableInstanceForFixed,
|
294 | getTableInstanceForExpand = _this$context.getTableInstanceForExpand;
|
295 |
|
296 | getTableInstance && getTableInstance(props.lockType, _this);
|
297 | getTableInstanceForFixed && getTableInstanceForFixed(props.lockType, _this);
|
298 | getTableInstanceForVirtual && getTableInstanceForVirtual(props.lockType, _this);
|
299 | getTableInstanceForExpand && getTableInstanceForExpand(_this);
|
300 | _this.notRenderCellIndex = [];
|
301 | return _this;
|
302 | }
|
303 |
|
304 | Table.prototype.getChildContext = function getChildContext() {
|
305 | return {
|
306 | notRenderCellIndex: this.notRenderCellIndex || [],
|
307 | lockType: this.props.lockType
|
308 | };
|
309 | };
|
310 |
|
311 | Table.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps) {
|
312 | var state = {};
|
313 |
|
314 | if (typeof nextProps.sort !== 'undefined') {
|
315 | state.sort = nextProps.sort;
|
316 | }
|
317 |
|
318 | return state;
|
319 | };
|
320 |
|
321 | Table.prototype.componentDidMount = function componentDidMount() {
|
322 | this.notRenderCellIndex = [];
|
323 | };
|
324 |
|
325 | Table.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState, nextContext) {
|
326 | if (nextProps.pure) {
|
327 | var isEqual = (0, _shallowElementEquals2.default)(nextProps, this.props) && _util.obj.shallowEqual(nextState, this.state) && _util.obj.shallowEqual(nextContext, this.context);
|
328 | return !isEqual;
|
329 | }
|
330 |
|
331 | return true;
|
332 | };
|
333 |
|
334 | Table.prototype.componentDidUpdate = function componentDidUpdate() {
|
335 | this.notRenderCellIndex = [];
|
336 | };
|
337 |
|
338 | Table.prototype.normalizeChildrenState = function normalizeChildrenState(props) {
|
339 | var columns = props.columns;
|
340 | if (props.children) {
|
341 | columns = this.normalizeChildren(props);
|
342 | }
|
343 | return this.fetchInfoFromBinaryChildren(columns);
|
344 | };
|
345 |
|
346 |
|
347 |
|
348 |
|
349 | Table.prototype.normalizeChildren = function normalizeChildren(props) {
|
350 | var columns = props.columns;
|
351 |
|
352 | var getChildren = function getChildren(children) {
|
353 | var ret = [];
|
354 | Children.forEach(children, function (child) {
|
355 | if (child) {
|
356 | var _props = (0, _extends3.default)({}, child.props);
|
357 |
|
358 | if (child.ref) {
|
359 | _props.ref = child.ref;
|
360 | }
|
361 |
|
362 | if (!(child && ['function', 'object'].indexOf((0, _typeof3.default)(child.type)) > -1 && (child.type._typeMark === 'column' || child.type._typeMark === 'columnGroup'))) {
|
363 | _util.log.warning('Use <Table.Column/>, <Table.ColumnGroup/> as child.');
|
364 | }
|
365 | ret.push(_props);
|
366 | if (child.props.children) {
|
367 | _props.children = getChildren(child.props.children);
|
368 | }
|
369 | }
|
370 | });
|
371 | return ret;
|
372 | };
|
373 | if (props.children) {
|
374 | columns = getChildren(props.children);
|
375 | }
|
376 | return columns;
|
377 | };
|
378 |
|
379 | Table.prototype.fetchInfoFromBinaryChildren = function fetchInfoFromBinaryChildren(children) {
|
380 | var hasGroupHeader = false;
|
381 | var flatChildren = [],
|
382 | groupChildren = [],
|
383 | getChildren = function getChildren() {
|
384 | var propsChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
385 | var level = arguments[1];
|
386 |
|
387 | groupChildren[level] = groupChildren[level] || [];
|
388 | propsChildren.forEach(function (child) {
|
389 | if (child.children) {
|
390 | hasGroupHeader = true;
|
391 | getChildren(child.children, level + 1);
|
392 | } else {
|
393 | flatChildren.push(child);
|
394 | }
|
395 | groupChildren[level].push(child);
|
396 | });
|
397 | },
|
398 | getColSpan = function getColSpan(children, colSpan) {
|
399 | colSpan = colSpan || 0;
|
400 | children.forEach(function (child) {
|
401 | if (child.children) {
|
402 | colSpan = getColSpan(child.children, colSpan);
|
403 | } else {
|
404 | colSpan += 1;
|
405 | }
|
406 | });
|
407 | return colSpan;
|
408 | };
|
409 |
|
410 | getChildren(children, 0);
|
411 |
|
412 | groupChildren.forEach(function (groupChild, i) {
|
413 | groupChild.forEach(function (child, j) {
|
414 | var colSpan = void 0;
|
415 | var children = child.children;
|
416 |
|
417 | if (children) {
|
418 | colSpan = getColSpan(children);
|
419 | child.colSpan = colSpan;
|
420 | groupChildren[i][j] = child;
|
421 | }
|
422 | });
|
423 | });
|
424 |
|
425 | var _props2 = this.props,
|
426 | lockType = _props2.lockType,
|
427 | lengths = _props2.lengths;
|
428 |
|
429 | var start = lockType === 'right' ? lengths.origin - lengths.right : 0;
|
430 | this.addColIndex(flatChildren, start);
|
431 |
|
432 | return {
|
433 | flatChildren: flatChildren,
|
434 | groupChildren: groupChildren,
|
435 | hasGroupHeader: hasGroupHeader
|
436 | };
|
437 | };
|
438 |
|
439 | Table.prototype.renderColGroup = function renderColGroup(flatChildren) {
|
440 | var cols = flatChildren.map(function (col, index) {
|
441 | var width = col.width;
|
442 | var style = {};
|
443 | if (width) {
|
444 | style = {
|
445 | width: width
|
446 | };
|
447 | }
|
448 |
|
449 | return _react2.default.createElement('col', { style: style, key: index });
|
450 | });
|
451 | return _react2.default.createElement(
|
452 | 'colgroup',
|
453 | { key: 'table-colgroup' },
|
454 | cols
|
455 | );
|
456 | };
|
457 |
|
458 |
|
459 | Table.prototype.renderTable = function renderTable(groupChildren, flatChildren) {
|
460 | if (flatChildren.length || !flatChildren.length && !this.props.lockType) {
|
461 | var _props3 = this.props,
|
462 | hasHeader = _props3.hasHeader,
|
463 | components = _props3.components,
|
464 | prefix = _props3.prefix,
|
465 | wrapperContent = _props3.wrapperContent,
|
466 | filterParams = _props3.filterParams,
|
467 | locale = _props3.locale,
|
468 | dataSource = _props3.dataSource,
|
469 | emptyContent = _props3.emptyContent,
|
470 | loading = _props3.loading,
|
471 | primaryKey = _props3.primaryKey,
|
472 | cellProps = _props3.cellProps,
|
473 | rowProps = _props3.rowProps,
|
474 | onRowClick = _props3.onRowClick,
|
475 | onRowMouseEnter = _props3.onRowMouseEnter,
|
476 | onRowMouseLeave = _props3.onRowMouseLeave,
|
477 | expandedIndexSimulate = _props3.expandedIndexSimulate,
|
478 | pure = _props3.pure,
|
479 | rtl = _props3.rtl,
|
480 | crossline = _props3.crossline,
|
481 | sortIcons = _props3.sortIcons,
|
482 | tableWidth = _props3.tableWidth;
|
483 | var sort = this.state.sort;
|
484 | var _components$Header = components.Header,
|
485 | Header = _components$Header === undefined ? _header2.default : _components$Header,
|
486 | _components$Wrapper = components.Wrapper,
|
487 | Wrapper = _components$Wrapper === undefined ? _wrapper2.default : _components$Wrapper,
|
488 | _components$Body = components.Body,
|
489 | Body = _components$Body === undefined ? _body2.default : _components$Body;
|
490 |
|
491 | var colGroup = this.renderColGroup(flatChildren);
|
492 |
|
493 | return [_react2.default.createElement('div', {
|
494 | key: prefix + 'table-column-resize-proxy',
|
495 | ref: this.getResizeProxyDomRef,
|
496 | className: prefix + 'table-column-resize-proxy'
|
497 | }), _react2.default.createElement(
|
498 | Wrapper,
|
499 | {
|
500 | key: prefix + 'table-wrapper',
|
501 | colGroup: colGroup,
|
502 | ref: this.getWrapperRef,
|
503 | prefix: prefix,
|
504 | tableWidth: tableWidth
|
505 | },
|
506 | hasHeader ? _react2.default.createElement(Header, {
|
507 | prefix: prefix,
|
508 | rtl: rtl,
|
509 | pure: pure,
|
510 | affixRef: this.getAffixRef,
|
511 | colGroup: colGroup,
|
512 | className: prefix + 'table-header',
|
513 | filterParams: filterParams,
|
514 | tableEl: this.tableEl,
|
515 | columns: groupChildren,
|
516 | locale: locale,
|
517 | headerCellRef: this.getHeaderCellRef,
|
518 | components: components,
|
519 | onFilter: this.onFilter,
|
520 | sort: sort,
|
521 | onResizeChange: this.onResizeChange,
|
522 | onSort: this.onSort,
|
523 | sortIcons: sortIcons,
|
524 | tableWidth: tableWidth,
|
525 | resizeProxyDomRef: this.resizeProxyDomRef
|
526 | }) : null,
|
527 | _react2.default.createElement(Body, {
|
528 | prefix: prefix,
|
529 | rtl: rtl,
|
530 | pure: pure,
|
531 | crossline: crossline,
|
532 | colGroup: colGroup,
|
533 | className: prefix + 'table-body',
|
534 | components: components,
|
535 | loading: loading,
|
536 | emptyContent: emptyContent,
|
537 | getCellProps: cellProps,
|
538 | primaryKey: primaryKey,
|
539 | getRowProps: rowProps,
|
540 | columns: flatChildren,
|
541 | rowRef: this.getRowRef,
|
542 | cellRef: this.getCellRef,
|
543 | onRowClick: onRowClick,
|
544 | expandedIndexSimulate: expandedIndexSimulate,
|
545 | tableEl: this.tableEl,
|
546 | onRowMouseEnter: onRowMouseEnter,
|
547 | onRowMouseLeave: onRowMouseLeave,
|
548 | dataSource: dataSource,
|
549 | locale: locale,
|
550 | onBodyMouseOver: this.onBodyMouseOver,
|
551 | onBodyMouseOut: this.onBodyMouseOut,
|
552 | tableWidth: tableWidth
|
553 | }),
|
554 | wrapperContent
|
555 | )];
|
556 | } else {
|
557 | return null;
|
558 | }
|
559 | };
|
560 |
|
561 | |
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 | Table.prototype.render = function render() {
|
568 | var _classnames;
|
569 |
|
570 | var ret = this.normalizeChildrenState(this.props);
|
571 | this.groupChildren = ret.groupChildren;
|
572 | this.flatChildren = ret.flatChildren;
|
573 |
|
574 | var table = this.renderTable(ret.groupChildren, ret.flatChildren),
|
575 | _props4 = this.props,
|
576 | className = _props4.className,
|
577 | style = _props4.style,
|
578 | hasBorder = _props4.hasBorder,
|
579 | isZebra = _props4.isZebra,
|
580 | loading = _props4.loading,
|
581 | size = _props4.size,
|
582 | hasHeader = _props4.hasHeader,
|
583 | prefix = _props4.prefix,
|
584 | dataSource = _props4.dataSource,
|
585 | entireDataSource = _props4.entireDataSource,
|
586 | onSort = _props4.onSort,
|
587 | onResizeChange = _props4.onResizeChange,
|
588 | onRowClick = _props4.onRowClick,
|
589 | onRowMouseEnter = _props4.onRowMouseEnter,
|
590 | onRowMouseLeave = _props4.onRowMouseLeave,
|
591 | onFilter = _props4.onFilter,
|
592 | rowProps = _props4.rowProps,
|
593 | cellProps = _props4.cellProps,
|
594 | scrollToRow = _props4.scrollToRow,
|
595 | primaryKey = _props4.primaryKey,
|
596 | components = _props4.components,
|
597 | wrapperContent = _props4.wrapperContent,
|
598 | lockType = _props4.lockType,
|
599 | locale = _props4.locale,
|
600 | expandedIndexSimulate = _props4.expandedIndexSimulate,
|
601 | refs = _props4.refs,
|
602 | pure = _props4.pure,
|
603 | rtl = _props4.rtl,
|
604 | emptyContent = _props4.emptyContent,
|
605 | filterParams = _props4.filterParams,
|
606 | columns = _props4.columns,
|
607 | sortIcons = _props4.sortIcons,
|
608 | _props4$loadingCompon = _props4.loadingComponent,
|
609 | LoadingComponent = _props4$loadingCompon === undefined ? _loading2.default : _props4$loadingCompon,
|
610 | tableLayout = _props4.tableLayout,
|
611 | tableWidth = _props4.tableWidth,
|
612 | ref = _props4.ref,
|
613 | others = (0, _objectWithoutProperties3.default)(_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']),
|
614 | cls = (0, _classnames3.default)((_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));
|
615 |
|
616 |
|
617 | if (rtl) {
|
618 | others.dir = 'rtl';
|
619 | }
|
620 |
|
621 | var content = _react2.default.createElement(
|
622 | 'div',
|
623 | (0, _extends3.default)({
|
624 | className: cls,
|
625 | style: style,
|
626 | ref: ref || this.getTableEl
|
627 | }, _util.obj.pickOthers(Object.keys(Table.propTypes), others)),
|
628 | table
|
629 | );
|
630 | if (loading) {
|
631 | var loadingClassName = prefix + 'table-loading';
|
632 | return _react2.default.createElement(
|
633 | LoadingComponent,
|
634 | { className: loadingClassName },
|
635 | content
|
636 | );
|
637 | }
|
638 | return content;
|
639 | };
|
640 |
|
641 | return Table;
|
642 | }(_react2.default.Component), _class.Column = _column2.default, _class.ColumnGroup = _columnGroup2.default, _class.Header = _header2.default, _class.Body = _body2.default, _class.Wrapper = _wrapper2.default, _class.Row = _row2.default, _class.Cell = _cell2.default, _class.Filter = _filter2.default, _class.Sort = _sort2.default, _class.propTypes = (0, _extends3.default)({}, _configProvider2.default.propTypes, {
|
643 | |
644 |
|
645 |
|
646 | prefix: _propTypes2.default.string,
|
647 | pure: _propTypes2.default.bool,
|
648 | rtl: _propTypes2.default.bool,
|
649 | |
650 |
|
651 |
|
652 | tableLayout: _propTypes2.default.oneOf(['fixed', 'auto']),
|
653 | |
654 |
|
655 |
|
656 | tableWidth: _propTypes2.default.number,
|
657 | |
658 |
|
659 |
|
660 | className: _propTypes2.default.string,
|
661 | |
662 |
|
663 |
|
664 | style: _propTypes2.default.object,
|
665 | |
666 |
|
667 |
|
668 | size: _propTypes2.default.oneOf(['small', 'medium']),
|
669 | |
670 |
|
671 |
|
672 | dataSource: _propTypes2.default.array,
|
673 | entireDataSource: _propTypes2.default.array,
|
674 | |
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 | onRowClick: _propTypes2.default.func,
|
681 | |
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 | onRowMouseEnter: _propTypes2.default.func,
|
688 | |
689 |
|
690 |
|
691 |
|
692 |
|
693 |
|
694 | onRowMouseLeave: _propTypes2.default.func,
|
695 | |
696 |
|
697 |
|
698 |
|
699 |
|
700 | onSort: _propTypes2.default.func,
|
701 | |
702 |
|
703 |
|
704 |
|
705 | onFilter: _propTypes2.default.func,
|
706 | |
707 |
|
708 |
|
709 |
|
710 |
|
711 | onResizeChange: _propTypes2.default.func,
|
712 | |
713 |
|
714 |
|
715 |
|
716 |
|
717 |
|
718 | rowProps: _propTypes2.default.func,
|
719 | |
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 | cellProps: _propTypes2.default.func,
|
728 | |
729 |
|
730 |
|
731 | hasBorder: _propTypes2.default.bool,
|
732 | |
733 |
|
734 |
|
735 | hasHeader: _propTypes2.default.bool,
|
736 | |
737 |
|
738 |
|
739 | isZebra: _propTypes2.default.bool,
|
740 | |
741 |
|
742 |
|
743 | loading: _propTypes2.default.bool,
|
744 | |
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 | loadingComponent: _propTypes2.default.func,
|
751 | |
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 | filterParams: _propTypes2.default.object,
|
758 | |
759 |
|
760 |
|
761 | sort: _propTypes2.default.object,
|
762 | |
763 |
|
764 |
|
765 | sortIcons: _propTypes2.default.object,
|
766 | |
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 | locale: _propTypes2.default.object,
|
779 | components: _propTypes2.default.object,
|
780 | |
781 |
|
782 |
|
783 | columns: _propTypes2.default.array,
|
784 | |
785 |
|
786 |
|
787 | emptyContent: _propTypes2.default.node,
|
788 | |
789 |
|
790 |
|
791 | primaryKey: _propTypes2.default.oneOfType([_propTypes2.default.symbol, _propTypes2.default.string]),
|
792 | lockType: _propTypes2.default.oneOf(['left', 'right']),
|
793 | wrapperContent: _propTypes2.default.any,
|
794 | refs: _propTypes2.default.object,
|
795 | |
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | expandedRowRender: _propTypes2.default.func,
|
802 | |
803 |
|
804 |
|
805 |
|
806 |
|
807 |
|
808 | rowExpandable: _propTypes2.default.func,
|
809 | |
810 |
|
811 |
|
812 | expandedRowIndent: _propTypes2.default.array,
|
813 | |
814 |
|
815 |
|
816 | hasExpandedRowCtrl: _propTypes2.default.bool,
|
817 | |
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 | getExpandedColProps: _propTypes2.default.func,
|
824 | |
825 |
|
826 |
|
827 | openRowKeys: _propTypes2.default.array,
|
828 | |
829 |
|
830 |
|
831 |
|
832 | defaultOpenRowKeys: _propTypes2.default.array,
|
833 | |
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 | onRowOpen: _propTypes2.default.func,
|
841 | onExpandedRowClick: _propTypes2.default.func,
|
842 | |
843 |
|
844 |
|
845 | fixedHeader: _propTypes2.default.bool,
|
846 | |
847 |
|
848 |
|
849 | maxBodyHeight: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
|
850 | |
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 | rowSelection: _propTypes2.default.object,
|
863 | |
864 |
|
865 |
|
866 | stickyHeader: _propTypes2.default.bool,
|
867 | |
868 |
|
869 |
|
870 | offsetTop: _propTypes2.default.number,
|
871 | |
872 |
|
873 |
|
874 | affixProps: _propTypes2.default.object,
|
875 | |
876 |
|
877 |
|
878 | indent: _propTypes2.default.number,
|
879 | |
880 |
|
881 |
|
882 | isTree: _propTypes2.default.bool,
|
883 | |
884 |
|
885 |
|
886 | useVirtual: _propTypes2.default.bool,
|
887 | rowHeight: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.func]),
|
888 | |
889 |
|
890 |
|
891 |
|
892 | scrollToRow: _propTypes2.default.number,
|
893 | |
894 |
|
895 |
|
896 | onBodyScroll: _propTypes2.default.func,
|
897 | |
898 |
|
899 |
|
900 | expandedIndexSimulate: _propTypes2.default.bool,
|
901 | |
902 |
|
903 |
|
904 | crossline: _propTypes2.default.bool,
|
905 | lengths: _propTypes2.default.object
|
906 | }), _class.defaultProps = {
|
907 | dataSource: [],
|
908 | onRowClick: noop,
|
909 | onRowMouseEnter: noop,
|
910 | onRowMouseLeave: noop,
|
911 | onSort: noop,
|
912 | onFilter: noop,
|
913 | onResizeChange: noop,
|
914 | size: 'medium',
|
915 | rowProps: noop,
|
916 | cellProps: noop,
|
917 | prefix: 'next-',
|
918 | hasBorder: true,
|
919 | hasHeader: true,
|
920 | isZebra: false,
|
921 | loading: false,
|
922 | expandedIndexSimulate: false,
|
923 | primaryKey: 'id',
|
924 | components: {},
|
925 | locale: _zhCn2.default.Table,
|
926 | crossline: false
|
927 | }, _class.childContextTypes = {
|
928 | notRenderCellIndex: _propTypes2.default.array,
|
929 | lockType: _propTypes2.default.oneOf(['left', 'right'])
|
930 | }, _class.contextTypes = {
|
931 | getTableInstance: _propTypes2.default.func,
|
932 | getTableInstanceForFixed: _propTypes2.default.func,
|
933 | getTableInstanceForVirtual: _propTypes2.default.func,
|
934 | getTableInstanceForExpand: _propTypes2.default.func
|
935 | }, _temp);
|
936 | Table.displayName = 'Table';
|
937 | exports.default = (0, _reactLifecyclesCompat.polyfill)(Table);
|
938 | module.exports = exports['default']; |
\ | No newline at end of file |