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

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.
@@ -71,6 +71,11 @@ export function treeMode() {
71
71
  return pipeline.mapDataSource(processDataSource).mapColumns(processColumns);
72
72
 
73
73
  function processDataSource(input) {
74
+ if (pipeline.isSameInputDataSource() && openKeys === pipeline.getFeatureOptions('lastOpenKeys')) {
75
+ return pipeline.getFeatureOptions('lastTreeMode');
76
+ }
77
+
78
+ pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey));
74
79
  var result = [];
75
80
  dfs(input, 0);
76
81
 
@@ -111,6 +116,7 @@ export function treeMode() {
111
116
  }
112
117
  }
113
118
 
119
+ pipeline.setFeatureOptions('lastTreeMode', result);
114
120
  return result;
115
121
  }
116
122
 
@@ -35,6 +35,7 @@ export declare class TablePipeline {
35
35
  private readonly _rowPropsGetters;
36
36
  private _tableProps;
37
37
  private _dataSource;
38
+ private _isSameInputDataSource;
38
39
  private _columns;
39
40
  private _footerDataSource?;
40
41
  static defaultIndents: TablePipelineIndentsConfig;
@@ -51,6 +52,7 @@ export declare class TablePipeline {
51
52
  appendRowPropsGetter(getter: RowPropsGetter): this;
52
53
  addTableProps(props: React.HTMLAttributes<HTMLTableElement>): void;
53
54
  getDataSource(name?: string): any[];
55
+ isSameInputDataSource(): boolean;
54
56
  getColumns(name?: string): any[];
55
57
  getFooterDataSource(): any[];
56
58
  getStateAtKey<T = any>(stateKey: string, defaultValue?: T): T;
@@ -76,6 +76,11 @@ export var TablePipeline = /*#__PURE__*/function () {
76
76
  return this._snapshots[name].dataSource;
77
77
  }
78
78
  }
79
+ }, {
80
+ key: "isSameInputDataSource",
81
+ value: function isSameInputDataSource() {
82
+ return this._isSameInputDataSource;
83
+ }
79
84
  }, {
80
85
  key: "getColumns",
81
86
  value: function getColumns(name) {
@@ -127,9 +132,12 @@ export var TablePipeline = /*#__PURE__*/function () {
127
132
 
128
133
  if (this._dataSource != null || this._columns != null) {
129
134
  throw new Error('input 不能调用两次');
130
- }
135
+ } // 在 pipeline 中识别本次更新是否有数据变化
136
+
131
137
 
138
+ this._isSameInputDataSource = _input.dataSource === this.ref.current._lastInputDataSource;
132
139
  this._dataSource = _input.dataSource;
140
+ this.ref.current._lastInputDataSource = _input.dataSource;
133
141
  this._columns = _mapInstanceProperty(_context = _input.columns).call(_context, function (col) {
134
142
  return _extends(_extends({}, col), {
135
143
  key: _this.guid()
@@ -101,6 +101,11 @@ function treeMode() {
101
101
  return pipeline.mapDataSource(processDataSource).mapColumns(processColumns);
102
102
 
103
103
  function processDataSource(input) {
104
+ if (pipeline.isSameInputDataSource() && openKeys === pipeline.getFeatureOptions('lastOpenKeys')) {
105
+ return pipeline.getFeatureOptions('lastTreeMode');
106
+ }
107
+
108
+ pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey));
104
109
  var result = [];
105
110
  dfs(input, 0);
106
111
 
@@ -143,6 +148,7 @@ function treeMode() {
143
148
  }
144
149
  }
145
150
 
151
+ pipeline.setFeatureOptions('lastTreeMode', result);
146
152
  return result;
147
153
  }
148
154
 
@@ -35,6 +35,7 @@ export declare class TablePipeline {
35
35
  private readonly _rowPropsGetters;
36
36
  private _tableProps;
37
37
  private _dataSource;
38
+ private _isSameInputDataSource;
38
39
  private _columns;
39
40
  private _footerDataSource?;
40
41
  static defaultIndents: TablePipelineIndentsConfig;
@@ -51,6 +52,7 @@ export declare class TablePipeline {
51
52
  appendRowPropsGetter(getter: RowPropsGetter): this;
52
53
  addTableProps(props: React.HTMLAttributes<HTMLTableElement>): void;
53
54
  getDataSource(name?: string): any[];
55
+ isSameInputDataSource(): boolean;
54
56
  getColumns(name?: string): any[];
55
57
  getFooterDataSource(): any[];
56
58
  getStateAtKey<T = any>(stateKey: string, defaultValue?: T): T;
@@ -92,6 +92,11 @@ var TablePipeline = /*#__PURE__*/function () {
92
92
  return this._snapshots[name].dataSource;
93
93
  }
94
94
  }
95
+ }, {
96
+ key: "isSameInputDataSource",
97
+ value: function isSameInputDataSource() {
98
+ return this._isSameInputDataSource;
99
+ }
95
100
  }, {
96
101
  key: "getColumns",
97
102
  value: function getColumns(name) {
@@ -143,9 +148,12 @@ var TablePipeline = /*#__PURE__*/function () {
143
148
 
144
149
  if (this._dataSource != null || this._columns != null) {
145
150
  throw new Error('input 不能调用两次');
146
- }
151
+ } // 在 pipeline 中识别本次更新是否有数据变化
152
+
147
153
 
154
+ this._isSameInputDataSource = _input.dataSource === this.ref.current._lastInputDataSource;
148
155
  this._dataSource = _input.dataSource;
156
+ this.ref.current._lastInputDataSource = _input.dataSource;
149
157
  this._columns = (0, _map.default)(_context = _input.columns).call(_context, function (col) {
150
158
  return (0, _extends3.default)((0, _extends3.default)({}, col), {
151
159
  key: _this.guid()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/table",
3
- "version": "1.2.0-canary.13",
3
+ "version": "1.2.0-canary.14",
4
4
  "description": "金蝶 react table 组件",
5
5
  "title": "table",
6
6
  "keywords": [