@kdcloudjs/table 1.2.0-canary.13 → 1.2.0-canary.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @kdcloudjs/table v1.2.0-canary.12
3
+ * @kdcloudjs/table v1.2.0-canary.14
4
4
  *
5
5
  * Copyright 2020-present, Kingdee, Inc.
6
6
  * All rights reserved.
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  *
3
- * @kdcloudjs/table v1.2.0-canary.12
3
+ * @kdcloudjs/table v1.2.0-canary.14
4
4
  *
5
5
  * Copyright 2020-present, Kingdee, Inc.
6
6
  * All rights reserved.
@@ -3945,18 +3945,21 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
3945
3945
  hasStickyScroll = _this$props6.hasStickyScroll,
3946
3946
  stickyBottom = _this$props6.stickyBottom;
3947
3947
  var hasScroll = this.state.hasScroll;
3948
+ var isScroll = hasStickyScroll && hasScroll;
3949
+ var stickyScrollContainerStyle = this.getStickyScrollContainerStyle();
3948
3950
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_27___default.a.createElement("div", {
3949
- className: classnames__WEBPACK_IMPORTED_MODULE_26___default()(_styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].horizontalScrollContainer, _styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].horizontalStickyScrollContainer)
3951
+ className: classnames__WEBPACK_IMPORTED_MODULE_26___default()(_styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].horizontalScrollContainer, _styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].horizontalStickyScrollContainer),
3952
+ style: stickyScrollContainerStyle
3950
3953
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_27___default.a.createElement("div", {
3951
3954
  className: classnames__WEBPACK_IMPORTED_MODULE_26___default()(_styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].horizontalScrollLeftSpacer),
3952
3955
  style: {
3953
3956
  width: info.leftLockTotalWidth,
3954
- display: hasStickyScroll && hasScroll ? 'block' : 'none'
3957
+ display: isScroll ? 'block' : 'none'
3955
3958
  }
3956
3959
  }), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_27___default.a.createElement("div", {
3957
3960
  className: classnames__WEBPACK_IMPORTED_MODULE_26___default()(_styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].stickyScroll),
3958
3961
  style: {
3959
- display: hasStickyScroll && hasScroll ? 'block' : 'none',
3962
+ display: isScroll ? 'block' : 'none',
3960
3963
  bottom: stickyBottom
3961
3964
  }
3962
3965
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_27___default.a.createElement("div", {
@@ -3965,7 +3968,7 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
3965
3968
  className: classnames__WEBPACK_IMPORTED_MODULE_26___default()(_styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].horizontalScrollRightSpacer),
3966
3969
  style: {
3967
3970
  width: info.rightLockTotalWidth,
3968
- display: hasStickyScroll && hasScroll ? 'block' : 'none'
3971
+ display: isScroll ? 'block' : 'none'
3969
3972
  }
3970
3973
  }));
3971
3974
  }
@@ -3974,6 +3977,22 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
3974
3977
  value: function getScrollBarWidth() {
3975
3978
  return this.props.scrollbarWidth || Object(_utils__WEBPACK_IMPORTED_MODULE_39__["getScrollbarSize"])().width;
3976
3979
  }
3980
+ }, {
3981
+ key: "getStickyScrollContainerStyle",
3982
+ value: function getStickyScrollContainerStyle() {
3983
+ var _this$props7 = this.props,
3984
+ hasStickyScroll = _this$props7.hasStickyScroll,
3985
+ stickyScrollHeight = _this$props7.stickyScrollHeight;
3986
+ var hasScroll = this.state.hasScroll;
3987
+ var isScroll = hasStickyScroll && hasScroll;
3988
+ var height = stickyScrollHeight === 'auto' ? this.getScrollBarWidth() : stickyScrollHeight;
3989
+ var stickyHeight = isScroll ? height : 0;
3990
+ return {
3991
+ height: stickyHeight,
3992
+ maxHeight: stickyHeight,
3993
+ minHeight: stickyHeight
3994
+ };
3995
+ }
3977
3996
  }, {
3978
3997
  key: "render",
3979
3998
  value: function render() {
@@ -3982,20 +4001,20 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
3982
4001
  // console.log('render table')
3983
4002
  var info = Object(_calculations__WEBPACK_IMPORTED_MODULE_30__["calculateRenderInfo"])(this);
3984
4003
  this.lastInfo = info;
3985
- var _this$props7 = this.props,
3986
- dataSource = _this$props7.dataSource,
3987
- className = _this$props7.className,
3988
- style = _this$props7.style,
3989
- hasHeader = _this$props7.hasHeader,
3990
- useOuterBorder = _this$props7.useOuterBorder,
3991
- isStickyHead = _this$props7.isStickyHead,
3992
- isStickyHeader = _this$props7.isStickyHeader,
3993
- isStickyFooter = _this$props7.isStickyFooter,
3994
- isLoading = _this$props7.isLoading,
3995
- getTableProps = _this$props7.getTableProps,
3996
- footerDataSource = _this$props7.footerDataSource,
3997
- components = _this$props7.components,
3998
- bordered = _this$props7.bordered;
4004
+ var _this$props8 = this.props,
4005
+ dataSource = _this$props8.dataSource,
4006
+ className = _this$props8.className,
4007
+ style = _this$props8.style,
4008
+ hasHeader = _this$props8.hasHeader,
4009
+ useOuterBorder = _this$props8.useOuterBorder,
4010
+ isStickyHead = _this$props8.isStickyHead,
4011
+ isStickyHeader = _this$props8.isStickyHeader,
4012
+ isStickyFooter = _this$props8.isStickyFooter,
4013
+ isLoading = _this$props8.isLoading,
4014
+ getTableProps = _this$props8.getTableProps,
4015
+ footerDataSource = _this$props8.footerDataSource,
4016
+ components = _this$props8.components,
4017
+ bordered = _this$props8.bordered;
3999
4018
  var artTableWrapperClassName = classnames__WEBPACK_IMPORTED_MODULE_26___default()(_styles__WEBPACK_IMPORTED_MODULE_38__["Classes"].artTableWrapper, (_cx = {
4000
4019
  'use-outer-border': useOuterBorder,
4001
4020
  empty: dataSource.length === 0,
@@ -4023,7 +4042,7 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
4023
4042
  }, {
4024
4043
  key: "componentDidMount",
4025
4044
  value: function componentDidMount() {
4026
- var _this$props$setTableW2, _this$props9, _this$props$setTableD, _this$props10, _this$props$setRowHei, _this$props11;
4045
+ var _this$props$setTableW2, _this$props10, _this$props$setTableD, _this$props11, _this$props$setRowHei, _this$props12;
4027
4046
 
4028
4047
  this.rootSubscription = new rxjs__WEBPACK_IMPORTED_MODULE_28__["Subscription"]();
4029
4048
  this.resizeSubject = new rxjs__WEBPACK_IMPORTED_MODULE_28__["Subject"]();
@@ -4032,31 +4051,31 @@ var BaseTable = /*#__PURE__*/function (_React$Component) {
4032
4051
  this.initSubscriptions();
4033
4052
  this.didMountOrUpdate(); // console.log('did mount end')
4034
4053
 
4035
- var _this$props8 = this.props,
4036
- cssVariables = _this$props8.cssVariables,
4037
- enableCSSVariables = _this$props8.enableCSSVariables,
4038
- bordered = _this$props8.bordered;
4054
+ var _this$props9 = this.props,
4055
+ cssVariables = _this$props9.cssVariables,
4056
+ enableCSSVariables = _this$props9.enableCSSVariables,
4057
+ bordered = _this$props9.bordered;
4039
4058
  Object(_utils__WEBPACK_IMPORTED_MODULE_39__["cssPolifill"])({
4040
4059
  variables: cssVariables || {},
4041
4060
  enableCSSVariables: enableCSSVariables,
4042
4061
  bordered: bordered
4043
4062
  });
4044
- (_this$props$setTableW2 = (_this$props9 = this.props).setTableWidth) === null || _this$props$setTableW2 === void 0 ? void 0 : _this$props$setTableW2.call(_this$props9, this.domHelper.tableBody.clientWidth);
4045
- (_this$props$setTableD = (_this$props10 = this.props).setTableDomHelper) === null || _this$props$setTableD === void 0 ? void 0 : _this$props$setTableD.call(_this$props10, this.domHelper);
4046
- (_this$props$setRowHei = (_this$props11 = this.props).setRowHeightManager) === null || _this$props$setRowHei === void 0 ? void 0 : _this$props$setRowHei.call(_this$props11, this.rowHeightManager);
4063
+ (_this$props$setTableW2 = (_this$props10 = this.props).setTableWidth) === null || _this$props$setTableW2 === void 0 ? void 0 : _this$props$setTableW2.call(_this$props10, this.domHelper.tableBody.clientWidth);
4064
+ (_this$props$setTableD = (_this$props11 = this.props).setTableDomHelper) === null || _this$props$setTableD === void 0 ? void 0 : _this$props$setTableD.call(_this$props11, this.domHelper);
4065
+ (_this$props$setRowHei = (_this$props12 = this.props).setRowHeightManager) === null || _this$props$setRowHei === void 0 ? void 0 : _this$props$setRowHei.call(_this$props12, this.rowHeightManager);
4047
4066
  }
4048
4067
  }, {
4049
4068
  key: "componentDidUpdate",
4050
4069
  value: function componentDidUpdate(prevProps, prevState) {
4051
- var _this$props13;
4070
+ var _this$props14;
4052
4071
 
4053
4072
  // console.log('did update start')
4054
- var _this$props12 = this.props,
4055
- cssVariables = _this$props12.cssVariables,
4056
- enableCSSVariables = _this$props12.enableCSSVariables,
4057
- bordered = _this$props12.bordered;
4073
+ var _this$props13 = this.props,
4074
+ cssVariables = _this$props13.cssVariables,
4075
+ enableCSSVariables = _this$props13.enableCSSVariables,
4076
+ bordered = _this$props13.bordered;
4058
4077
 
4059
- if (!Object(_utils__WEBPACK_IMPORTED_MODULE_39__["shallowEqual"])(prevProps === null || prevProps === void 0 ? void 0 : prevProps.cssVariables, (_this$props13 = this.props) === null || _this$props13 === void 0 ? void 0 : _this$props13.cssVariables)) {
4078
+ if (!Object(_utils__WEBPACK_IMPORTED_MODULE_39__["shallowEqual"])(prevProps === null || prevProps === void 0 ? void 0 : prevProps.cssVariables, (_this$props14 = this.props) === null || _this$props14 === void 0 ? void 0 : _this$props14.cssVariables)) {
4060
4079
  Object(_utils__WEBPACK_IMPORTED_MODULE_39__["cssPolifill"])({
4061
4080
  variables: cssVariables || {},
4062
4081
  enableCSSVariables: enableCSSVariables,
@@ -10806,6 +10825,11 @@ function treeMode() {
10806
10825
  return pipeline.mapDataSource(processDataSource).mapColumns(processColumns);
10807
10826
 
10808
10827
  function processDataSource(input) {
10828
+ if (pipeline.isSameInputDataSource() && openKeys === pipeline.getFeatureOptions('lastOpenKeys')) {
10829
+ return pipeline.getFeatureOptions('lastTreeMode');
10830
+ }
10831
+
10832
+ pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey));
10809
10833
  var result = [];
10810
10834
  dfs(input, 0);
10811
10835
 
@@ -10846,6 +10870,7 @@ function treeMode() {
10846
10870
  }
10847
10871
  }
10848
10872
 
10873
+ pipeline.setFeatureOptions('lastTreeMode', result);
10849
10874
  return result;
10850
10875
  }
10851
10876
 
@@ -11289,6 +11314,8 @@ var TablePipeline = /*#__PURE__*/function () {
11289
11314
 
11290
11315
  _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_10___default()(this, "_dataSource", void 0);
11291
11316
 
11317
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_10___default()(this, "_isSameInputDataSource", void 0);
11318
+
11292
11319
  _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_10___default()(this, "_columns", void 0);
11293
11320
 
11294
11321
  _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_10___default()(this, "_footerDataSource", void 0);
@@ -11340,6 +11367,11 @@ var TablePipeline = /*#__PURE__*/function () {
11340
11367
  return this._snapshots[name].dataSource;
11341
11368
  }
11342
11369
  }
11370
+ }, {
11371
+ key: "isSameInputDataSource",
11372
+ value: function isSameInputDataSource() {
11373
+ return this._isSameInputDataSource;
11374
+ }
11343
11375
  }, {
11344
11376
  key: "getColumns",
11345
11377
  value: function getColumns(name) {
@@ -11390,9 +11422,12 @@ var TablePipeline = /*#__PURE__*/function () {
11390
11422
 
11391
11423
  if (this._dataSource != null || this._columns != null) {
11392
11424
  throw new Error('input 不能调用两次');
11393
- }
11425
+ } // 在 pipeline 中识别本次更新是否有数据变化
11426
+
11394
11427
 
11428
+ this._isSameInputDataSource = _input.dataSource === this.ref.current._lastInputDataSource;
11395
11429
  this._dataSource = _input.dataSource;
11430
+ this.ref.current._lastInputDataSource = _input.dataSource;
11396
11431
  this._columns = _input.columns.map(function (col) {
11397
11432
  return _objectSpread(_objectSpread({}, col), {}, {
11398
11433
  key: _this.guid()