UNPKG

33.1 kBJavaScriptView Raw
1'use strict';
2
3exports.__esModule = true;
4
5var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
6
7var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
8
9var _typeof2 = require('babel-runtime/helpers/typeof');
10
11var _typeof3 = _interopRequireDefault(_typeof2);
12
13var _extends2 = require('babel-runtime/helpers/extends');
14
15var _extends3 = _interopRequireDefault(_extends2);
16
17var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
18
19var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
20
21var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
22
23var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
24
25var _inherits2 = require('babel-runtime/helpers/inherits');
26
27var _inherits3 = _interopRequireDefault(_inherits2);
28
29exports.default = lock;
30
31var _react = require('react');
32
33var _react2 = _interopRequireDefault(_react);
34
35var _reactDom = require('react-dom');
36
37var _propTypes = require('prop-types');
38
39var _propTypes2 = _interopRequireDefault(_propTypes);
40
41var _classnames2 = require('classnames');
42
43var _classnames3 = _interopRequireDefault(_classnames2);
44
45var _shallowElementEquals = require('shallow-element-equals');
46
47var _shallowElementEquals2 = _interopRequireDefault(_shallowElementEquals);
48
49var _util = require('../util');
50
51var _row = require('./lock/row');
52
53var _row2 = _interopRequireDefault(_row);
54
55var _body = require('./lock/body');
56
57var _body2 = _interopRequireDefault(_body);
58
59var _header = require('./lock/header');
60
61var _header2 = _interopRequireDefault(_header);
62
63var _wrapper = require('./fixed/wrapper');
64
65var _wrapper2 = _interopRequireDefault(_wrapper);
66
67var _util2 = require('./util');
68
69function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
70
71var ieVersion = _util.env.ieVersion;
72function lock(BaseComponent) {
73 var _class, _temp;
74
75 /** Table */
76 var LockTable = (_temp = _class = function (_React$Component) {
77 (0, _inherits3.default)(LockTable, _React$Component);
78
79 function LockTable(props, context) {
80 (0, _classCallCheck3.default)(this, LockTable);
81
82 var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props, context));
83
84 _this.state = {};
85
86 _this.getTableInstance = function (type, instance) {
87 type = type ? type.charAt(0).toUpperCase() + type.substr(1) : '';
88 _this['table' + type + 'Inc'] = instance;
89 };
90
91 _this.getNode = function (type, node, lockType) {
92 lockType = lockType ? lockType.charAt(0).toUpperCase() + lockType.substr(1) : '';
93 _this['' + type + lockType + 'Node'] = node;
94 if (type === 'header' && !_this.innerHeaderNode && !lockType) {
95 _this.innerHeaderNode = _this.headerNode.querySelector('div');
96 }
97 };
98
99 _this.onRowMouseEnter = function (record, index) {
100 if (_this.isLock()) {
101 var row = _this.getRowNode(index);
102 var leftRow = _this.getRowNode(index, 'left');
103 var rightRow = _this.getRowNode(index, 'right');
104 [row, leftRow, rightRow].forEach(function (row) {
105 row && _util.dom.addClass(row, 'hovered');
106 });
107 }
108 };
109
110 _this.onRowMouseLeave = function (record, index) {
111 if (_this.isLock()) {
112 var row = _this.getRowNode(index);
113 var leftRow = _this.getRowNode(index, 'left');
114 var rightRow = _this.getRowNode(index, 'right');
115 [row, leftRow, rightRow].forEach(function (row) {
116 row && _util.dom.removeClass(row, 'hovered');
117 });
118 }
119 };
120
121 _this.onLockBodyScrollTop = function (event) {
122 // set scroll top for lock columns & main body
123 var target = event.target;
124 if (event.currentTarget !== target) {
125 return;
126 }
127 var distScrollTop = target.scrollTop;
128
129 if (_this.isLock() && distScrollTop !== _this.lastScrollTop) {
130 var lockRightBody = _this.bodyRightNode,
131 lockLeftBody = _this.bodyLeftNode,
132 bodyNode = _this.bodyNode;
133
134 var arr = [lockLeftBody, lockRightBody, bodyNode];
135
136 arr.forEach(function (node) {
137 if (node && node.scrollTop !== distScrollTop) {
138 node.scrollTop = distScrollTop;
139 }
140 });
141
142 _this.lastScrollTop = distScrollTop;
143 }
144 };
145
146 _this.onLockBodyScrollLeft = function () {
147 // add shadow class for lock columns
148 if (_this.isLock()) {
149 var rtl = _this.props.rtl;
150
151 var lockRightTable = rtl ? _this.getWrapperNode('left') : _this.getWrapperNode('right'),
152 lockLeftTable = rtl ? _this.getWrapperNode('right') : _this.getWrapperNode('left'),
153 shadowClassName = 'shadow';
154
155 var x = _this.bodyNode.scrollLeft;
156
157 if (x === 0) {
158 lockLeftTable && _util.dom.removeClass(lockLeftTable, shadowClassName);
159 lockRightTable && _util.dom.addClass(lockRightTable, shadowClassName);
160 } else if (x === _this.bodyNode.scrollWidth - _this.bodyNode.clientWidth) {
161 lockLeftTable && _util.dom.addClass(lockLeftTable, shadowClassName);
162 lockRightTable && _util.dom.removeClass(lockRightTable, shadowClassName);
163 } else {
164 lockLeftTable && _util.dom.addClass(lockLeftTable, shadowClassName);
165 lockRightTable && _util.dom.addClass(lockRightTable, shadowClassName);
166 }
167 }
168 };
169
170 _this.onLockBodyScroll = function (event) {
171 _this.onLockBodyScrollTop(event);
172 _this.onLockBodyScrollLeft();
173 };
174
175 _this.adjustSize = function () {
176 if (!_this.adjustIfTableNotNeedLock()) {
177 _this.adjustHeaderSize();
178 _this.adjustBodySize();
179 _this.adjustRowHeight();
180 _this.onLockBodyScrollLeft();
181 }
182 };
183
184 _this.getFlatenChildrenLength = function () {
185 var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
186
187 var loop = function loop(arr) {
188 var newArray = [];
189 arr.forEach(function (child) {
190 if (child && child.children) {
191 newArray.push.apply(newArray, loop(child.children));
192 } else {
193 newArray.push(child);
194 }
195 });
196 return newArray;
197 };
198
199 return loop(children).length;
200 };
201
202 _this.saveLockLeftRef = function (ref) {
203 _this.lockLeftEl = ref;
204 };
205
206 _this.saveLockRightRef = function (ref) {
207 _this.lockRightEl = ref;
208 };
209
210 _this.lockLeftChildren = [];
211 _this.lockRightChildren = [];
212 return _this;
213 }
214
215 LockTable.prototype.getChildContext = function getChildContext() {
216 return {
217 getTableInstance: this.getTableInstance,
218 getLockNode: this.getNode,
219 onLockBodyScroll: this.onLockBodyScroll,
220 onRowMouseEnter: this.onRowMouseEnter,
221 onRowMouseLeave: this.onRowMouseLeave
222 };
223 };
224
225 LockTable.prototype.componentDidMount = function componentDidMount() {
226 _util.events.on(window, 'resize', this.adjustSize);
227
228 this.scroll();
229 this.adjustSize();
230 this.forceUpdate();
231 };
232
233 LockTable.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState, nextContext) {
234 if (nextProps.pure) {
235 var isEqual = (0, _shallowElementEquals2.default)(nextProps, this.props);
236 return !(isEqual && _util.obj.shallowEqual(nextContext, this.context));
237 }
238
239 return true;
240 };
241
242 LockTable.prototype.componentDidUpdate = function componentDidUpdate() {
243 this.adjustSize();
244 this._isLock = false;
245 };
246
247 LockTable.prototype.componentWillUnmount = function componentWillUnmount() {
248 _util.events.off(window, 'resize', this.adjustSize);
249 };
250
251 LockTable.prototype.normalizeChildrenState = function normalizeChildrenState(props) {
252 var columns = this.normalizeChildren(props);
253 var splitChildren = this.splitFromNormalizeChildren(columns);
254 var lockLeftChildren = splitChildren.lockLeftChildren,
255 lockRightChildren = splitChildren.lockRightChildren;
256
257 return {
258 lockLeftChildren: lockLeftChildren,
259 lockRightChildren: lockRightChildren,
260 children: this.mergeFromSplitLockChildren(splitChildren)
261 };
262 };
263
264 // 将React结构化数据提取props转换成数组
265
266
267 LockTable.prototype.normalizeChildren = function normalizeChildren(props) {
268 var children = props.children,
269 columns = props.columns;
270
271 var isLock = false,
272 ret = void 0;
273 var checkLock = function checkLock(col) {
274 if ([true, 'left', 'right'].indexOf(col.lock) > -1) {
275 if (!('width' in col)) {
276 _util.log.warning('Should config width for lock column named [ ' + col.dataIndex + ' ].');
277 }
278 isLock = true;
279 }
280 };
281 if (columns && !children) {
282 ret = columns;
283
284 var getColumns = function getColumns(cols) {
285 cols.forEach(function () {
286 var col = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
287
288 checkLock(col);
289
290 if (col.children) {
291 getColumns(col.children);
292 }
293 });
294 };
295
296 getColumns(columns);
297 } else {
298 var getChildren = function getChildren(children) {
299 var ret = [];
300 _react.Children.forEach(children, function (child) {
301 if (child) {
302 var _props = (0, _extends3.default)({}, child.props);
303 checkLock(_props);
304 ret.push(_props);
305 if (child.props.children) {
306 _props.children = getChildren(child.props.children);
307 }
308 }
309 });
310 return ret;
311 };
312
313 ret = getChildren(children);
314 }
315
316 ret.forEach(function (child) {
317 // 为自定义的列特殊处理
318 if (child.__normalized && isLock) {
319 // users can set lock type for column selection now, so its origin lock type comes first
320 child.lock = child.lock || 'left';
321 delete child.__normalized;
322 }
323 });
324 this._isLock = isLock;
325 return ret;
326 };
327
328 //从数组中分离出lock的列和正常的列
329
330
331 LockTable.prototype.splitFromNormalizeChildren = function splitFromNormalizeChildren(children) {
332 var originChildren = deepCopy(children);
333 var lockLeftChildren = deepCopy(children);
334 var lockRightChildren = deepCopy(children);
335 var loop = function loop(lockChildren, condition) {
336 var ret = [];
337 lockChildren.forEach(function (child) {
338 if (child.children) {
339 var res = loop(child.children, condition);
340 if (!res.length) {
341 ret.push(child);
342 }
343 } else {
344 var order = condition(child);
345 if (!order) {
346 ret.push(child);
347 }
348 }
349 });
350 ret.forEach(function (res) {
351 var index = lockChildren.indexOf(res);
352 lockChildren.splice(index, 1);
353 });
354 return lockChildren;
355 };
356 loop(lockLeftChildren, function (child) {
357 if (child.lock === true || child.lock === 'left') {
358 return 'left';
359 }
360 });
361 loop(lockRightChildren, function (child) {
362 if (child.lock === 'right') {
363 return 'right';
364 }
365 });
366 loop(originChildren, function (child) {
367 return child.lock !== true && child.lock !== 'left' && child.lock !== 'right';
368 });
369 return {
370 lockLeftChildren: lockLeftChildren,
371 lockRightChildren: lockRightChildren,
372 originChildren: originChildren
373 };
374 };
375
376 //将左侧的锁列树和中间的普通树及右侧的锁列树进行合并
377
378
379 LockTable.prototype.mergeFromSplitLockChildren = function mergeFromSplitLockChildren(splitChildren) {
380 var lockLeftChildren = splitChildren.lockLeftChildren,
381 lockRightChildren = splitChildren.lockRightChildren;
382 var originChildren = splitChildren.originChildren;
383
384 Array.prototype.unshift.apply(originChildren, lockLeftChildren);
385 originChildren = originChildren.concat(lockRightChildren);
386 return originChildren;
387 };
388
389 LockTable.prototype.scroll = function scroll() {
390 var _props2 = this.props,
391 _props2$scrollToCol = _props2.scrollToCol,
392 scrollToCol = _props2$scrollToCol === undefined ? 0 : _props2$scrollToCol,
393 _props2$scrollToRow = _props2.scrollToRow,
394 scrollToRow = _props2$scrollToRow === undefined ? 0 : _props2$scrollToRow;
395
396 if (!scrollToCol && !scrollToRow || !this.bodyNode) {
397 return;
398 }
399 var colCellNode = this.getCellNode(0, scrollToCol);
400 var rowCellNode = this.getCellNode(scrollToRow, 0);
401 var bodyNodeOffset = this.bodyNode.getBoundingClientRect() || {};
402 if (colCellNode) {
403 var cellNodeoffset = colCellNode.getBoundingClientRect();
404 var scrollLeft = cellNodeoffset.left - bodyNodeOffset.left;
405 this.bodyNode.scrollLeft = scrollLeft;
406 }
407 if (rowCellNode) {
408 var _cellNodeoffset = rowCellNode.getBoundingClientRect();
409 var scrollTop = _cellNodeoffset.top - bodyNodeOffset.top;
410 this.bodyNode.scrollTop = scrollTop;
411 }
412 };
413
414 // Table处理过后真实的lock状态
415 LockTable.prototype.isLock = function isLock() {
416 return this.lockLeftChildren.length || this.lockRightChildren.length;
417 };
418
419 // 用户设置的lock状态
420
421
422 LockTable.prototype.isOriginLock = function isOriginLock() {
423 return this._isLock;
424 };
425
426 LockTable.prototype.removeLockTable = function removeLockTable() {
427 var lockLeftLen = this.lockLeftChildren.length;
428 var lockRightLen = this.lockRightChildren.length;
429
430 if (lockLeftLen) {
431 this._notNeedAdjustLockLeft = true;
432 }
433 if (lockRightLen) {
434 this._notNeedAdjustLockRight = true;
435 }
436 if (lockRightLen || lockLeftLen) {
437 this.forceUpdate();
438 return true;
439 }
440 };
441
442 LockTable.prototype.adjustIfTableNotNeedLock = function adjustIfTableNotNeedLock() {
443 var _this2 = this;
444
445 if (this.isOriginLock()) {
446 var widthObj = this.tableInc.flatChildren.map(function (item, index) {
447 var cell = _this2.getCellNode(0, index) || {};
448 var headerCell = _this2.getHeaderCellNode(0, index) || {};
449
450 // fix https://codesandbox.io/s/fusion-next-template-d9bu8
451 // close #1832
452 try {
453 return {
454 cellWidths: parseFloat(getComputedStyle(cell).width) || 0,
455 headerWidths: parseFloat(getComputedStyle(headerCell).width) || 0
456 };
457 } catch (error) {
458 return {
459 cellWidths: cell.clientWidth || 0,
460 headerWidths: headerCell.clientWidth || 0
461 };
462 }
463 }).reduce(function (a, b) {
464 return {
465 cellWidths: a.cellWidths + b.cellWidths,
466 headerWidths: a.headerWidths + b.headerWidths
467 };
468 }, {
469 cellWidths: 0,
470 headerWidths: 0
471 });
472
473 var node = void 0,
474 width = void 0;
475
476 try {
477 node = (0, _reactDom.findDOMNode)(this);
478 width = node.clientWidth;
479 } catch (err) {
480 node = null;
481 width = 0;
482 }
483
484 // if the table doesn't exist, there is no need to adjust
485 if (width === 0) {
486 return true;
487 }
488
489 var configWidths = parseInt(widthObj.cellWidths) || parseInt(widthObj.headerWidths);
490
491 if (configWidths <= width && configWidths > 0) {
492 this.removeLockTable();
493 } else if (this._notNeedAdjustLockLeft || this._notNeedAdjustLockRight) {
494 this._notNeedAdjustLockLeft = this._notNeedAdjustLockRight = false;
495 this.forceUpdate();
496 } else {
497 this._notNeedAdjustLockLeft = this._notNeedAdjustLockRight = false;
498 return false;
499 }
500 }
501
502 return false;
503 };
504
505 LockTable.prototype.adjustBodySize = function adjustBodySize() {
506 var _style;
507
508 var _props3 = this.props,
509 rtl = _props3.rtl,
510 hasHeader = _props3.hasHeader;
511
512 var header = this.headerNode;
513 var paddingName = rtl ? 'paddingLeft' : 'paddingRight';
514 var marginName = rtl ? 'marginLeft' : 'marginRight';
515 var scrollBarSize = +_util.dom.scrollbar().width || 0;
516 var style = (_style = {}, _style[paddingName] = scrollBarSize, _style[marginName] = scrollBarSize, _style);
517 var body = this.bodyNode,
518 hasVerScroll = body && body.scrollHeight > body.clientHeight;
519
520 if (this.isLock()) {
521 var lockLeftBody = this.bodyLeftNode,
522 lockRightBody = this.bodyRightNode,
523 lockRightBodyWrapper = this.getWrapperNode('right'),
524 bodyHeight = body.offsetHeight,
525 width = hasVerScroll ? scrollBarSize : 0,
526 lockBodyHeight = bodyHeight - scrollBarSize;
527
528 if (!hasVerScroll) {
529 style[paddingName] = 0;
530 style[marginName] = 0;
531 }
532 if (+scrollBarSize) {
533 style.marginBottom = -scrollBarSize;
534 style.paddingBottom = scrollBarSize;
535 } else {
536 style.marginBottom = -20;
537 style.paddingBottom = 20;
538 }
539
540 var lockStyle = {
541 'max-height': lockBodyHeight
542 };
543 if (!hasHeader && !+scrollBarSize) {
544 lockStyle[marginName] = 0;
545 }
546 if (+scrollBarSize) {
547 lockStyle[marginName] = -scrollBarSize;
548 }
549 lockLeftBody && _util.dom.setStyle(lockLeftBody, lockStyle);
550 lockRightBody && _util.dom.setStyle(lockRightBody, lockStyle);
551 lockRightBodyWrapper && +scrollBarSize && _util.dom.setStyle(lockRightBodyWrapper, rtl ? 'left' : 'right', width + 'px');
552 } else {
553 style.marginBottom = -scrollBarSize;
554 style.paddingBottom = scrollBarSize;
555 style[marginName] = 0;
556 if (!hasVerScroll) {
557 style[paddingName] = 0;
558 }
559 }
560
561 header && _util.dom.setStyle(header, style);
562 };
563
564 LockTable.prototype.adjustHeaderSize = function adjustHeaderSize() {
565 var _this3 = this;
566
567 if (this.isLock()) {
568 this.tableInc.groupChildren.forEach(function (child, index) {
569 var lastIndex = _this3.tableInc.groupChildren[index].length - 1;
570 var headerRightRow = _this3.getHeaderCellNode(index, lastIndex),
571 headerLeftRow = _this3.getHeaderCellNode(index, 0),
572 headerRightLockRow = _this3.getHeaderCellNode(index, 0, 'right'),
573 headerLeftLockRow = _this3.getHeaderCellNode(index, 0, 'left');
574
575 if (headerRightRow && headerRightLockRow) {
576 var maxRightRowHeight = headerRightRow.offsetHeight;
577
578 _util.dom.setStyle(headerRightLockRow, 'height', maxRightRowHeight);
579
580 setTimeout(function () {
581 var affixRef = _this3.tableRightInc.affixRef;
582 // if rendered then update postion of affix
583 return affixRef && affixRef.getInstance() && affixRef.getInstance().updatePosition();
584 });
585 }
586
587 if (headerLeftRow && headerLeftLockRow) {
588 var maxLeftRowHeight = headerLeftRow.offsetHeight;
589
590 _util.dom.setStyle(headerLeftLockRow, 'height', maxLeftRowHeight);
591
592 setTimeout(function () {
593 var affixRef = _this3.tableLeftInc.affixRef;
594 // if rendered then update postion of affix
595 return affixRef && affixRef.getInstance() && affixRef.getInstance().updatePosition();
596 });
597 }
598 });
599 }
600 };
601
602 LockTable.prototype.adjustRowHeight = function adjustRowHeight() {
603 var _this4 = this;
604
605 if (this.isLock()) {
606 this.tableInc.props.dataSource.forEach(function (item, index) {
607 // record may be a string
608 var rowIndex = '' + ((typeof item === 'undefined' ? 'undefined' : (0, _typeof3.default)(item)) === 'object' && '__rowIndex' in item ? item.__rowIndex : index) + (item.__expanded ? '_expanded' : '');
609
610 // 同步左侧的锁列
611 _this4.setRowHeight(rowIndex, 'left');
612 // 同步右侧的锁列
613 _this4.setRowHeight(rowIndex, 'right');
614 });
615 }
616 };
617
618 LockTable.prototype.setRowHeight = function setRowHeight(rowIndex, dir) {
619 var lockRow = this.getRowNode(rowIndex, dir),
620 row = this.getRowNode(rowIndex),
621 rowHeight = (ieVersion ? row && row.offsetHeight : row && parseFloat(getComputedStyle(row).height)) || 'auto',
622 lockHeight = (ieVersion ? lockRow && lockRow.offsetHeight : lockRow && parseFloat(getComputedStyle(lockRow).height)) || 'auto';
623
624 if (lockRow && rowHeight !== lockHeight) {
625 _util.dom.setStyle(lockRow, 'height', rowHeight);
626 }
627 };
628
629 LockTable.prototype.getWrapperNode = function getWrapperNode(type) {
630 type = type ? type.charAt(0).toUpperCase() + type.substr(1) : '';
631 try {
632 // in case of finding an unmounted component due to cached data
633 // need to clear refs of table when dataSource Changed
634 // use try catch for temporary
635 return (0, _reactDom.findDOMNode)(this['lock' + type + 'El']);
636 } catch (error) {
637 return null;
638 }
639 };
640
641 // remove this in next major version, keep this for temperary incase of using it
642 // getFirstNormalCellNode(index) {
643 // let i = 0;
644 // let row;
645 // do {
646 // row = this.getCellNode(index, i);
647 // i++;
648 // } while (
649 // (!row || (row && row.rowSpan && row.rowSpan > 1)) &&
650 // this.tableInc.flatChildren.length > i
651 // );
652
653 // return row;
654 // }
655
656 LockTable.prototype.getRowNode = function getRowNode(index, type) {
657 type = type ? type.charAt(0).toUpperCase() + type.substr(1) : '';
658 var table = this['table' + type + 'Inc'];
659
660 try {
661 // in case of finding an unmounted component due to cached data
662 // need to clear refs of table when dataSource Changed
663 // use try catch for temporary
664 return (0, _reactDom.findDOMNode)(table.getRowRef(index));
665 } catch (error) {
666 return null;
667 }
668 };
669
670 LockTable.prototype.getHeaderCellNode = function getHeaderCellNode(index, i, type) {
671 type = type ? type.charAt(0).toUpperCase() + type.substr(1) : '';
672 var table = this['table' + type + 'Inc'];
673
674 try {
675 // in case of finding an unmounted component due to cached data
676 // need to clear refs of table when dataSource Changed
677 // use try catch for temporary
678 return (0, _reactDom.findDOMNode)(table.getHeaderCellRef(index, i));
679 } catch (error) {
680 return null;
681 }
682 };
683
684 LockTable.prototype.getCellNode = function getCellNode(index, i, type) {
685 type = type ? type.charAt(0).toUpperCase() + type.substr(1) : '';
686 var table = this['table' + type + 'Inc'];
687
688 try {
689 // in case of finding an unmounted component due to cached data
690 // need to clear refs of table when dataSource Changed
691 // use try catch for temporary
692 return (0, _reactDom.findDOMNode)(table.getCellRef(index, i));
693 } catch (error) {
694 return null;
695 }
696 };
697
698 LockTable.prototype.render = function render() {
699 /* eslint-disable no-unused-vars, prefer-const */
700 var _props4 = this.props,
701 children = _props4.children,
702 columns = _props4.columns,
703 prefix = _props4.prefix,
704 components = _props4.components,
705 className = _props4.className,
706 dataSource = _props4.dataSource,
707 tableWidth = _props4.tableWidth,
708 others = (0, _objectWithoutProperties3.default)(_props4, ['children', 'columns', 'prefix', 'components', 'className', 'dataSource', 'tableWidth']);
709
710 var _normalizeChildrenSta = this.normalizeChildrenState(this.props),
711 lockLeftChildren = _normalizeChildrenSta.lockLeftChildren,
712 lockRightChildren = _normalizeChildrenSta.lockRightChildren,
713 normalizedChildren = _normalizeChildrenSta.children;
714
715 var leftLen = this.getFlatenChildrenLength(lockLeftChildren);
716 var rightLen = this.getFlatenChildrenLength(lockRightChildren);
717 var originLen = this.getFlatenChildrenLength(normalizedChildren);
718
719 var lengths = {
720 left: leftLen,
721 right: rightLen,
722 origin: originLen
723 };
724 if (this._notNeedAdjustLockLeft) {
725 lockLeftChildren = [];
726 }
727 if (this._notNeedAdjustLockRight) {
728 lockRightChildren = [];
729 }
730 this.lockLeftChildren = lockLeftChildren;
731 this.lockRightChildren = lockRightChildren;
732
733 if (this.isOriginLock()) {
734 var _classnames;
735
736 components = (0, _extends3.default)({}, components);
737 components.Body = components.Body || _body2.default;
738 components.Header = components.Header || _header2.default;
739 components.Wrapper = components.Wrapper || _wrapper2.default;
740 components.Row = components.Row || _row2.default;
741 className = (0, _classnames3.default)((_classnames = {}, _classnames[prefix + 'table-lock'] = true, _classnames[prefix + 'table-wrap-empty'] = !dataSource.length, _classnames[className] = className, _classnames));
742 var content = [_react2.default.createElement(BaseComponent, (0, _extends3.default)({}, others, {
743 dataSource: dataSource,
744 key: 'lock-left',
745 columns: lockLeftChildren,
746 className: prefix + 'table-lock-left',
747 lengths: lengths,
748 prefix: prefix,
749 lockType: 'left',
750 components: components,
751 ref: this.saveLockLeftRef,
752 loading: false,
753 'aria-hidden': true
754 })), _react2.default.createElement(BaseComponent, (0, _extends3.default)({}, others, {
755 dataSource: dataSource,
756 key: 'lock-right',
757 columns: lockRightChildren,
758 className: prefix + 'table-lock-right',
759 lengths: lengths,
760 prefix: prefix,
761 lockType: 'right',
762 components: components,
763 ref: this.saveLockRightRef,
764 loading: false,
765 'aria-hidden': true
766 }))];
767 return _react2.default.createElement(BaseComponent, (0, _extends3.default)({}, others, {
768 tableWidth: tableWidth,
769 dataSource: dataSource,
770 columns: normalizedChildren,
771 prefix: prefix,
772 lengths: lengths,
773 wrapperContent: content,
774 components: components,
775 className: className
776 }));
777 }
778 return _react2.default.createElement(BaseComponent, this.props);
779 };
780
781 return LockTable;
782 }(_react2.default.Component), _class.LockRow = _row2.default, _class.LockBody = _body2.default, _class.LockHeader = _header2.default, _class.propTypes = (0, _extends3.default)({
783 scrollToCol: _propTypes2.default.number,
784 /**
785 * 指定滚动到某一行,仅在`useVirtual`的时候生效
786 */
787 scrollToRow: _propTypes2.default.number
788 }, BaseComponent.propTypes), _class.defaultProps = (0, _extends3.default)({}, BaseComponent.defaultProps), _class.childContextTypes = {
789 getTableInstance: _propTypes2.default.func,
790 getLockNode: _propTypes2.default.func,
791 onLockBodyScroll: _propTypes2.default.func,
792 onRowMouseEnter: _propTypes2.default.func,
793 onRowMouseLeave: _propTypes2.default.func
794 }, _temp);
795 LockTable.displayName = 'LockTable';
796
797 (0, _util2.statics)(LockTable, BaseComponent);
798 return LockTable;
799}
800
801function deepCopy(arr) {
802 var copy = function copy(arr) {
803 return arr.map(function (item) {
804 var newItem = (0, _extends3.default)({}, item);
805 if (item.children) {
806 item.children = copy(item.children);
807 }
808 return newItem;
809 });
810 };
811 return copy(arr);
812}
813module.exports = exports['default'];
\No newline at end of file