UNPKG

@txdfe/at

Version:

一个设计体系组件库

766 lines (625 loc) 31.5 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = lock; var _react = _interopRequireWildcard(require("react")); var _reactDom = require("react-dom"); var _propTypes = _interopRequireDefault(require("prop-types")); var _classnames2 = _interopRequireDefault(require("classnames")); var _shallowElementEquals = _interopRequireDefault(require("shallow-element-equals")); var _util = require("../util"); var _row = _interopRequireDefault(require("./lock/row")); var _body = _interopRequireDefault(require("./lock/body")); var _header = _interopRequireDefault(require("./lock/header")); var _wrapper = _interopRequireDefault(require("./fixed/wrapper")); var _util2 = require("./util"); var _excluded = ["children", "prefix", "components", "className"]; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 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 lock(BaseComponent) { /** Table */ var LockTable = /*#__PURE__*/function (_React$Component) { _inherits(LockTable, _React$Component); var _super = _createSuper(LockTable); function LockTable(props, context) { var _this; _classCallCheck(this, LockTable); _this = _super.call(this, props, context); _defineProperty(_assertThisInitialized(_this), "getTableInstance", function (type, instance) { type = type ? type.charAt(0).toUpperCase() + type.substr(1) : ''; _this["table".concat(type, "Inc")] = instance; }); _defineProperty(_assertThisInitialized(_this), "getNode", function (type, node, lockType) { lockType = lockType ? lockType.charAt(0).toUpperCase() + lockType.substr(1) : ''; _this["".concat(type).concat(lockType, "Node")] = node; if (type === 'header' && !_this.innerHeaderNode && !lockType) { _this.innerHeaderNode = _this.headerNode.querySelector('div'); } }); _defineProperty(_assertThisInitialized(_this), "onRowMouseEnter", function (record, index) { if (_this.isLock()) { var row = _this.getRowNode(index); var leftRow = _this.getRowNode(index, 'left'); var rightRow = _this.getRowNode(index, 'right'); [row, leftRow, rightRow].forEach(function (row) { row && _util.dom.addClass(row, 'hovered'); }); } }); _defineProperty(_assertThisInitialized(_this), "onRowMouseLeave", function (record, index) { if (_this.isLock()) { var row = _this.getRowNode(index); var leftRow = _this.getRowNode(index, 'left'); var rightRow = _this.getRowNode(index, 'right'); [row, leftRow, rightRow].forEach(function (row) { row && _util.dom.removeClass(row, 'hovered'); }); } }); _defineProperty(_assertThisInitialized(_this), "onLockBodyWheel", function (e) { var y = e.deltaY; var x = e.deltaX; var thresholdX = 15; var safeScrollX = x > -thresholdX && x < thresholdX; if (_this.isLock()) { var lockRightBody = _this.bodyRightNode; var lockLeftBody = _this.bodyLeftNode; var scrollNode = _this.bodyNode; var scrollTop = scrollNode.scrollTop, clientHeight = scrollNode.clientHeight, scrollHeight = scrollNode.scrollHeight; if (lockLeftBody) { lockLeftBody.scrollTop = y; } if (lockRightBody) { lockRightBody.scrollTop = y; } scrollNode.scrollTop = scrollTop + y; var newScrollTop = scrollNode.scrollTop; if (newScrollTop + clientHeight < scrollHeight && newScrollTop && safeScrollX) { e.preventDefault(); } } }); _defineProperty(_assertThisInitialized(_this), "onLockBodyScroll", function () { if (_this.isLock()) { var rtl = _this.props.rtl; var lockRightBody = _this.bodyRightNode; var lockLeftBody = _this.bodyLeftNode; var lockRightTable = rtl ? _this.getWrapperNode('left') : _this.getWrapperNode('right'); var lockLeftTable = rtl ? _this.getWrapperNode('right') : _this.getWrapperNode('left'); var shadowClassName = 'shadow'; var x = _this.bodyNode.scrollLeft; var y = _this.bodyNode.scrollTop; if (lockLeftBody) { lockLeftBody.scrollTop = y; } if (lockRightBody) { lockRightBody.scrollTop = y; } if (x === 0) { lockLeftTable && _util.dom.removeClass(lockLeftTable, shadowClassName); lockRightTable && _util.dom.addClass(lockRightTable, shadowClassName); } else if (x === _this.bodyNode.scrollWidth - _this.bodyNode.clientWidth) { lockLeftTable && _util.dom.addClass(lockLeftTable, shadowClassName); lockRightTable && _util.dom.removeClass(lockRightTable, shadowClassName); } else { lockLeftTable && _util.dom.addClass(lockLeftTable, shadowClassName); lockRightTable && _util.dom.addClass(lockRightTable, shadowClassName); } } }); _this.lockLeftChildren = []; _this.lockRightChildren = []; return _this; } _createClass(LockTable, [{ key: "getChildContext", value: function getChildContext() { return { getTableInstance: this.getTableInstance, getLockNode: this.getNode, onLockBodyWheel: this.onLockBodyWheel, onLockBodyScroll: this.onLockBodyScroll, onRowMouseEnter: this.onRowMouseEnter, onRowMouseLeave: this.onRowMouseLeave }; } }, { key: "componentDidMount", value: function componentDidMount() { this.adjustSize = this.adjustSize.bind(this); this.adjustSize(); this.scroll(); _util.events.on(window, 'resize', this.adjustSize); } }, { key: "shouldComponentUpdate", value: function shouldComponentUpdate(nextProps, nextState, nextContext) { if (nextProps.pure) { var isEqual = (0, _shallowElementEquals["default"])(nextProps, this.props); return !(isEqual && _util.obj.shallowEqual(nextContext, this.context)); } return true; } }, { key: "UNSAFE_componentWillUpdate", value: function UNSAFE_componentWillUpdate() { this._isLock = false; } }, { key: "componentDidUpdate", value: function componentDidUpdate() { this.adjustSize(); } }, { key: "componentWillUnmount", value: function componentWillUnmount() { _util.events.off(window, 'resize', this.adjustSize); } }, { key: "normalizeChildrenState", value: function normalizeChildrenState(props) { var children = props.children; children = this.normalizeChildren(children); var splitChildren = this.splitFromNormalizeChildren(children); var lockLeftChildren = splitChildren.lockLeftChildren, lockRightChildren = splitChildren.lockRightChildren; return { lockLeftChildren: lockLeftChildren, lockRightChildren: lockRightChildren, children: this.mergeFromSplitLockChildren(splitChildren) }; } // 将React结构化数据提取props转换成数组 }, { key: "normalizeChildren", value: function normalizeChildren(children) { var isLock = false; var getChildren = function getChildren(children) { var ret = []; _react.Children.forEach(children, function (child) { if (child) { var props = _objectSpread({}, child.props); if ([true, 'left', 'right'].indexOf(props.lock) > -1) { isLock = true; if (!('width' in props)) { _util.log.warning("Should config width for lock column named [ ".concat(props.dataIndex, " ].")); } } ret.push(props); if (child.props.children) { props.children = getChildren(child.props.children); } } }); return ret; }; var ret = getChildren(children); ret.forEach(function (child) { // 为自定义的列特殊处理 if (child.__normalized && isLock) { // users can set lock type for column selection now, so its origin lock type comes first child.lock = child.lock || 'left'; delete child.__normalized; } }); this._isLock = isLock; return ret; } // 从数组中分离出lock的列和正常的列 }, { key: "splitFromNormalizeChildren", value: function splitFromNormalizeChildren(children) { var originChildren = deepCopy(children); var lockLeftChildren = deepCopy(children); var lockRightChildren = deepCopy(children); var loop = function loop(lockChildren, condition) { var ret = []; lockChildren.forEach(function (child) { if (child.children) { var res = loop(child.children, condition); if (!res.length) { ret.push(child); } } else { var order = condition(child); if (!order) { ret.push(child); } } }); ret.forEach(function (res) { var index = lockChildren.indexOf(res); lockChildren.splice(index, 1); }); return lockChildren; }; loop(lockLeftChildren, function (child) { if (child.lock === true || child.lock === 'left') { return 'left'; } }); loop(lockRightChildren, function (child) { if (child.lock === 'right') { return 'right'; } }); loop(originChildren, function (child) { return child.lock !== true && child.lock !== 'left' && child.lock !== 'right'; }); return { lockLeftChildren: lockLeftChildren, lockRightChildren: lockRightChildren, originChildren: originChildren }; } // 将左侧的锁列树和中间的普通树及右侧的锁列树进行合并 }, { key: "mergeFromSplitLockChildren", value: function mergeFromSplitLockChildren(splitChildren) { var lockLeftChildren = splitChildren.lockLeftChildren, lockRightChildren = splitChildren.lockRightChildren; var originChildren = splitChildren.originChildren; Array.prototype.unshift.apply(originChildren, lockLeftChildren); originChildren = originChildren.concat(lockRightChildren); return originChildren; } }, { key: "scroll", value: function scroll() { var _this$props = this.props, _this$props$scrollToC = _this$props.scrollToCol, scrollToCol = _this$props$scrollToC === void 0 ? 0 : _this$props$scrollToC, _this$props$scrollToR = _this$props.scrollToRow, scrollToRow = _this$props$scrollToR === void 0 ? 0 : _this$props$scrollToR; if (!scrollToCol && !scrollToRow) { return; } var colCellNode = this.getCellNode(0, scrollToCol); var rowCellNode = this.getCellNode(scrollToRow, 0); var bodyNodeOffset = this.bodyNode.getBoundingClientRect(); if (colCellNode) { var cellNodeoffset = colCellNode.getBoundingClientRect(); var scrollLeft = cellNodeoffset.left - bodyNodeOffset.left; this.bodyNode.scrollLeft = scrollLeft; } if (rowCellNode) { var _cellNodeoffset = rowCellNode.getBoundingClientRect(); var scrollTop = _cellNodeoffset.top - bodyNodeOffset.top; this.bodyNode.scrollTop = scrollTop; } } }, { key: "isLock", value: // Table处理过后真实的lock状态 function isLock() { return this.lockLeftChildren.length || this.lockRightChildren.length; } // 用户设置的lock状态 }, { key: "isOriginLock", value: function isOriginLock() { return this._isLock; } }, { key: "adjustSize", value: function adjustSize() { if (!this.adjustIfTableNotNeedLock()) { this.adjustHeaderSize(); this.adjustBodySize(); this.adjustCellSize(); this.onLockBodyScroll(); } } }, { key: "removeLockTable", value: function removeLockTable() { var lockLeftLen = this.lockLeftChildren.length; var lockRightLen = this.lockRightChildren.length; if (lockLeftLen) { this._notNeedAdjustLockLeft = true; } if (lockRightLen) { this._notNeedAdjustLockRight = true; } if (lockRightLen || lockLeftLen) { this.forceUpdate(); return true; } } }, { key: "adjustIfTableNotNeedLock", value: function adjustIfTableNotNeedLock() { var _this2 = this; if (this.isOriginLock()) { var widthObj = this.tableInc.flatChildren.map(function (item, index) { var cell = _this2.getCellNode(0, index) || {}; var headerCell = _this2.getHeaderCellNode(0, index) || {}; return { cellWidths: cell.clientWidth || 0, headerWidths: headerCell.clientWidth || 0 }; }).reduce(function (a, b) { return { cellWidths: a.cellWidths + b.cellWidths, headerWidths: a.headerWidths + b.headerWidths }; }, { cellWidths: 0, headerWidths: 0 }); var node = (0, _reactDom.findDOMNode)(this); var width = node.clientWidth; // if the table doesn't exist, there is no need to adjust if (width === 0) { return true; } var configWidths = widthObj.cellWidths || widthObj.headerWidths; if (configWidths <= width && configWidths > 0) { this.removeLockTable(); } else if (this._notNeedAdjustLockLeft || this._notNeedAdjustLockRight) { this._notNeedAdjustLockLeft = this._notNeedAdjustLockRight = false; this.forceUpdate(); } else { this._notNeedAdjustLockLeft = this._notNeedAdjustLockRight = false; return false; } } return false; } }, { key: "adjustBodySize", value: function adjustBodySize() { if (this.isLock()) { var rtl = this.props.rtl; var body = this.bodyNode; var lockLeftBody = this.bodyLeftNode; var lockRightBody = this.bodyRightNode; var lockRightBodyWrapper = this.getWrapperNode('right'); var scrollbar = _util.dom.scrollbar(); var bodyHeight = body.offsetHeight; var hasHozScroll = body.scrollWidth > body.clientWidth; var hasVerScroll = body.scrollHeight > body.clientHeight; var width = hasVerScroll ? scrollbar.width : 0; var lockBodyHeight = bodyHeight - (hasHozScroll ? scrollbar.height : 0); lockLeftBody && _util.dom.setStyle(lockLeftBody, 'max-height', lockBodyHeight); lockRightBody && _util.dom.setStyle(lockRightBody, 'max-height', lockBodyHeight); lockRightBodyWrapper && _util.dom.setStyle(lockRightBodyWrapper, rtl ? 'left' : 'right', "".concat(width, "px")); } } }, { key: "adjustHeaderSize", value: function adjustHeaderSize() { var _this3 = this; if (this.isLock()) { this.tableInc.groupChildren.forEach(function (child, index) { var lastIndex = _this3.tableInc.groupChildren[index].length - 1; var headerRightRow = _this3.getHeaderCellNode(index, lastIndex); var headerLeftRow = _this3.getHeaderCellNode(index, 0); var headerRightLockRow = _this3.getHeaderCellNode(index, 0, 'right'); var headerLeftLockRow = _this3.getHeaderCellNode(index, 0, 'left'); if (headerRightRow && headerRightLockRow) { var maxRightRowHeight = headerRightRow.offsetHeight; _util.dom.setStyle(headerRightLockRow, 'height', maxRightRowHeight); setTimeout(function () { var affixRef = _this3.tableRightInc.affixRef; // if rendered then update postion of affix return affixRef && affixRef.getInstance() && affixRef.getInstance().updatePosition(); }); } if (headerLeftRow && headerLeftLockRow) { var maxLeftRowHeight = headerLeftRow.offsetHeight; _util.dom.setStyle(headerLeftLockRow, 'height', maxLeftRowHeight); setTimeout(function () { var affixRef = _this3.tableLeftInc.affixRef; // if rendered then update postion of affix return affixRef && affixRef.getInstance() && affixRef.getInstance().updatePosition(); }); } }); } } }, { key: "adjustCellSize", value: function adjustCellSize() { var _this4 = this; if (this.isLock()) { this.tableInc.props.dataSource.forEach(function (item, index) { var lockLeftRow = _this4.getCellNode(index, 0, 'left'); var lockRightRow = _this4.getCellNode(index, 0, 'right'); var row = _this4.getFirstNormalCellNode(index); var rowHeight = row && parseFloat(getComputedStyle(row).height) || 0; var lockLeftHeight = 0; var lockRightHeight = 0; if (lockLeftRow) { lockLeftHeight = lockLeftRow.offsetHeight; } if (lockRightRow) { lockRightHeight = lockRightRow.offsetHeight; } if (lockLeftRow && rowHeight !== lockLeftHeight) { _util.dom.setStyle(lockLeftRow, 'height', rowHeight); } if (lockRightRow && rowHeight !== lockRightHeight) { _util.dom.setStyle(lockRightRow, 'height', rowHeight); } }); } } }, { key: "getWrapperNode", value: function getWrapperNode(type) { type = type ? type.charAt(0).toUpperCase() + type.substr(1) : ''; try { // in case of finding an unmounted component due to cached data // need to clear refs of table when dataSource Changed // use try catch for temporary return (0, _reactDom.findDOMNode)(this.refs["lock".concat(type)]); } catch (error) { return null; } } }, { key: "getFirstNormalCellNode", value: function getFirstNormalCellNode(index) { var i = 0; var row; do { row = this.getCellNode(index, i); i++; } while ((!row || row && row.rowSpan && row.rowSpan > 1) && this.tableInc.flatChildren.length > i); return row; } }, { key: "getRowNode", value: function getRowNode(index, type) { type = type ? type.charAt(0).toUpperCase() + type.substr(1) : ''; var table = this["table".concat(type, "Inc")]; try { // in case of finding an unmounted component due to cached data // need to clear refs of table when dataSource Changed // use try catch for temporary return (0, _reactDom.findDOMNode)(table.getRowRef(index)); } catch (error) { return null; } } }, { key: "getHeaderCellNode", value: function getHeaderCellNode(index, i, type) { type = type ? type.charAt(0).toUpperCase() + type.substr(1) : ''; var table = this["table".concat(type, "Inc")]; try { // in case of finding an unmounted component due to cached data // need to clear refs of table when dataSource Changed // use try catch for temporary return (0, _reactDom.findDOMNode)(table.getHeaderCellRef(index, i)); } catch (error) { return null; } } }, { key: "getCellNode", value: function getCellNode(index, i, type) { type = type ? type.charAt(0).toUpperCase() + type.substr(1) : ''; var table = this["table".concat(type, "Inc")]; try { // in case of finding an unmounted component due to cached data // need to clear refs of table when dataSource Changed // use try catch for temporary return (0, _reactDom.findDOMNode)(table.getCellRef(index, i)); } catch (error) { return null; } } }, { key: "render", value: function render() { /* eslint-disable no-unused-vars, prefer-const */ var _this$props2 = this.props, children = _this$props2.children, prefix = _this$props2.prefix, components = _this$props2.components, className = _this$props2.className, others = _objectWithoutProperties(_this$props2, _excluded); var _this$normalizeChildr = this.normalizeChildrenState(this.props), lockLeftChildren = _this$normalizeChildr.lockLeftChildren, lockRightChildren = _this$normalizeChildr.lockRightChildren, normalizedChildren = _this$normalizeChildr.children; if (this._notNeedAdjustLockLeft) { lockLeftChildren = []; } if (this._notNeedAdjustLockRight) { lockRightChildren = []; } this.lockLeftChildren = lockLeftChildren; this.lockRightChildren = lockRightChildren; if (this.isOriginLock()) { var _classnames; components = _objectSpread({}, components); components.Body = components.Body || _body["default"]; components.Header = components.Header || _header["default"]; components.Wrapper = components.Wrapper || _wrapper["default"]; components.Row = components.Row || _row["default"]; className = (0, _classnames2["default"])((_classnames = {}, _defineProperty(_classnames, "".concat(prefix, "table-lock"), true), _defineProperty(_classnames, className, className), _classnames)); var content = [/*#__PURE__*/_react["default"].createElement(BaseComponent, _extends({}, others, { key: "lock-left", columns: lockLeftChildren, className: "".concat(prefix, "table-lock-left"), prefix: prefix, lockType: "left", components: components, ref: "lockLeft", loading: false, "aria-hidden": true })), /*#__PURE__*/_react["default"].createElement(BaseComponent, _extends({}, others, { key: "lock-right", columns: lockRightChildren, className: "".concat(prefix, "table-lock-right"), prefix: prefix, lockType: "right", components: components, ref: "lockRight", loading: false, "aria-hidden": true }))]; return /*#__PURE__*/_react["default"].createElement(BaseComponent, _extends({}, others, { columns: normalizedChildren, prefix: prefix, wrapperContent: content, components: components, className: className })); } return /*#__PURE__*/_react["default"].createElement(BaseComponent, this.props); } }]); return LockTable; }(_react["default"].Component); _defineProperty(LockTable, "LockRow", _row["default"]); _defineProperty(LockTable, "LockBody", _body["default"]); _defineProperty(LockTable, "LockHeader", _header["default"]); _defineProperty(LockTable, "propTypes", _objectSpread({ scrollToCol: _propTypes["default"].number, /** * 指定滚动到某一行,仅在`useVirtual`的时候生效 */ scrollToRow: _propTypes["default"].number }, BaseComponent.propTypes)); _defineProperty(LockTable, "defaultProps", _objectSpread({}, BaseComponent.defaultProps)); _defineProperty(LockTable, "childContextTypes", { getTableInstance: _propTypes["default"].func, getLockNode: _propTypes["default"].func, onLockBodyScroll: _propTypes["default"].func, onLockBodyWheel: _propTypes["default"].func, onRowMouseEnter: _propTypes["default"].func, onRowMouseLeave: _propTypes["default"].func }); (0, _util2.statics)(LockTable, BaseComponent); return LockTable; } function deepCopy(arr) { var copy = function copy(arr) { return arr.map(function (item) { var newItem = _objectSpread({}, item); if (item.children) { item.children = copy(item.children); } return newItem; }); }; return copy(arr); }