@kdcloudjs/table 1.2.0 → 1.2.1-canary.1
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.
- package/dist/@kdcloudjs/table.css +1 -1
- package/dist/@kdcloudjs/table.js +35 -15
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +6 -6
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/table/base/helpers/getRichVisibleRectsStream.js +2 -1
- package/es/table/pipeline/features/multiSelect.js +31 -12
- package/es/table/pipeline/features/treeMode.js +1 -1
- package/lib/table/base/helpers/getRichVisibleRectsStream.js +2 -1
- package/lib/table/pipeline/features/multiSelect.js +33 -12
- package/lib/table/pipeline/features/treeMode.js +1 -1
- package/package.json +3 -3
|
@@ -164,7 +164,8 @@ function getScrollParent(elem) {
|
|
|
164
164
|
|
|
165
165
|
|
|
166
166
|
export function getRichVisibleRectsStream(target, structureMayChange$, virtualDebugLabel) {
|
|
167
|
-
return structureMayChange$.pipe(op.
|
|
167
|
+
return structureMayChange$.pipe(op.mapTo(target), op.distinctUntilChanged(shallowEqual), // 当target没有发生变化时,无需重新查找
|
|
168
|
+
op.startWith('init'), op.map(function () {
|
|
168
169
|
// target 的第一个滚动父元素,我们认为这就是虚拟滚动发生的地方
|
|
169
170
|
// 即虚拟滚动不考虑「更上层元素发生滚动」的情况
|
|
170
171
|
// 直接从父元素开始查找,防止自身设置overflow属性导致是同一个元素
|
|
@@ -7,6 +7,9 @@ import React from 'react';
|
|
|
7
7
|
import { internals } from '../../internals';
|
|
8
8
|
import { always, arrayUtils } from '../../utils/others';
|
|
9
9
|
import { collectNodes, mergeCellProps, MULTI_SELECT_MARK_PROPNAME } from '../../utils';
|
|
10
|
+
var fullRowsSetKey = 'fullRowsSetKey';
|
|
11
|
+
var allEnableKeys = 'allEnableKeys';
|
|
12
|
+
var selectValueSetKey = 'selectValueSetKey';
|
|
10
13
|
export function multiSelect() {
|
|
11
14
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
15
|
return function multiSelectStep(pipeline) {
|
|
@@ -37,10 +40,9 @@ export function multiSelect() {
|
|
|
37
40
|
action: action
|
|
38
41
|
});
|
|
39
42
|
};
|
|
40
|
-
|
|
41
|
-
var dataSource = pipeline.getDataSource();
|
|
42
43
|
/** dataSource 中包含的所有 keys */
|
|
43
44
|
|
|
45
|
+
|
|
44
46
|
var fullKeySet = new _Set();
|
|
45
47
|
/** 所有有效的 keys(disable 状态为 false) */
|
|
46
48
|
|
|
@@ -49,7 +51,7 @@ export function multiSelect() {
|
|
|
49
51
|
var isAllChecked = set.size !== 0; // 当前不存在选中则默认为false
|
|
50
52
|
|
|
51
53
|
var isAnyChecked = false;
|
|
52
|
-
var flatDataSource = collectNodes(
|
|
54
|
+
var flatDataSource = collectNodes(pipeline.getDataSource());
|
|
53
55
|
flatDataSource.forEach(function (row, rowIndex) {
|
|
54
56
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
55
57
|
fullKeySet.add(rowKey); // 在 allKeys 中排除被禁用的 key
|
|
@@ -77,6 +79,8 @@ export function multiSelect() {
|
|
|
77
79
|
checked: isAllChecked,
|
|
78
80
|
indeterminate: !isAllChecked && isAnyChecked,
|
|
79
81
|
onChange: function onChange(_) {
|
|
82
|
+
var allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
83
|
+
|
|
80
84
|
if (isAllChecked) {
|
|
81
85
|
_onChange(arrayUtils.diff(value, allKeys), '', allKeys, 'uncheck-all');
|
|
82
86
|
} else {
|
|
@@ -97,9 +101,11 @@ export function multiSelect() {
|
|
|
97
101
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
98
102
|
var checkboxCellProps = {};
|
|
99
103
|
var preCellProps = (_b = (_a = opts.checkboxColumn) === null || _a === void 0 ? void 0 : _a.getCellProps) === null || _b === void 0 ? void 0 : _b.call(_a, value, row, rowIndex);
|
|
104
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _Set();
|
|
105
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
100
106
|
|
|
101
|
-
if (
|
|
102
|
-
var prevChecked =
|
|
107
|
+
if (fullRowsSet.has(rowKey) && clickArea === 'cell') {
|
|
108
|
+
var prevChecked = selectValueSet.has(rowKey);
|
|
103
109
|
var disabled = isDisabled(row, rowIndex);
|
|
104
110
|
checkboxCellProps = {
|
|
105
111
|
style: {
|
|
@@ -123,7 +129,8 @@ export function multiSelect() {
|
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
var key = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
126
|
-
var
|
|
132
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
133
|
+
var checked = selectValueSet.has(key);
|
|
127
134
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
128
135
|
checked: checked,
|
|
129
136
|
disabled: isDisabled(row, rowIndex),
|
|
@@ -163,8 +170,9 @@ export function multiSelect() {
|
|
|
163
170
|
|
|
164
171
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
165
172
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
173
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _Set();
|
|
166
174
|
|
|
167
|
-
if (!
|
|
175
|
+
if (!fullRowsSet.has(rowKey)) {
|
|
168
176
|
// rowKey 不在 fullKeySet 中说明这一行是在 multiSelect 之后才生成的,multiSelect 不对之后生成的行进行处理
|
|
169
177
|
return;
|
|
170
178
|
}
|
|
@@ -172,7 +180,8 @@ export function multiSelect() {
|
|
|
172
180
|
var style = {};
|
|
173
181
|
var className;
|
|
174
182
|
var onClick;
|
|
175
|
-
var
|
|
183
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
184
|
+
var checked = selectValueSet.has(rowKey);
|
|
176
185
|
|
|
177
186
|
if (opts.highlightRowWhenSelected && checked) {
|
|
178
187
|
className = 'highlight';
|
|
@@ -199,22 +208,32 @@ export function multiSelect() {
|
|
|
199
208
|
style: style,
|
|
200
209
|
onClick: onClick
|
|
201
210
|
};
|
|
202
|
-
});
|
|
211
|
+
}); // 只保留一份到pipeline, 避免行数据过多时内容被握住
|
|
212
|
+
|
|
213
|
+
pipeline.setFeatureOptions(fullRowsSetKey, fullKeySet);
|
|
214
|
+
pipeline.setFeatureOptions(allEnableKeys, allKeys);
|
|
215
|
+
pipeline.setFeatureOptions(selectValueSetKey, set);
|
|
216
|
+
fullKeySet = null;
|
|
217
|
+
allKeys = null;
|
|
218
|
+
set = null;
|
|
203
219
|
return pipeline;
|
|
204
220
|
|
|
205
221
|
function onCheckboxChange(prevChecked, key, batch) {
|
|
206
222
|
var batchKeys = [key];
|
|
207
223
|
|
|
208
224
|
if (batch && lastKey) {
|
|
209
|
-
var
|
|
210
|
-
|
|
225
|
+
var _allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
226
|
+
|
|
227
|
+
var lastIdx = _allKeys.indexOf(lastKey);
|
|
228
|
+
|
|
229
|
+
var cntIdx = _allKeys.indexOf(key);
|
|
211
230
|
|
|
212
231
|
var _ref = lastIdx < cntIdx ? [lastIdx, cntIdx] : [cntIdx, lastIdx],
|
|
213
232
|
_ref2 = _slicedToArray(_ref, 2),
|
|
214
233
|
start = _ref2[0],
|
|
215
234
|
end = _ref2[1];
|
|
216
235
|
|
|
217
|
-
batchKeys = _sliceInstanceProperty(
|
|
236
|
+
batchKeys = _sliceInstanceProperty(_allKeys).call(_allKeys, start, end + 1);
|
|
218
237
|
}
|
|
219
238
|
|
|
220
239
|
if (prevChecked) {
|
|
@@ -75,7 +75,7 @@ export function treeMode() {
|
|
|
75
75
|
return pipeline.getFeatureOptions('lastTreeMode');
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey)
|
|
78
|
+
pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey));
|
|
79
79
|
var result = [];
|
|
80
80
|
dfs(input, 0);
|
|
81
81
|
|
|
@@ -194,7 +194,8 @@ function getScrollParent(elem) {
|
|
|
194
194
|
|
|
195
195
|
|
|
196
196
|
function getRichVisibleRectsStream(target, structureMayChange$, virtualDebugLabel) {
|
|
197
|
-
return structureMayChange$.pipe(op.
|
|
197
|
+
return structureMayChange$.pipe(op.mapTo(target), op.distinctUntilChanged(_utils.shallowEqual), // 当target没有发生变化时,无需重新查找
|
|
198
|
+
op.startWith('init'), op.map(function () {
|
|
198
199
|
// target 的第一个滚动父元素,我们认为这就是虚拟滚动发生的地方
|
|
199
200
|
// 即虚拟滚动不考虑「更上层元素发生滚动」的情况
|
|
200
201
|
// 直接从父元素开始查找,防止自身设置overflow属性导致是同一个元素
|
|
@@ -25,6 +25,10 @@ var _others = require("../../utils/others");
|
|
|
25
25
|
|
|
26
26
|
var _utils = require("../../utils");
|
|
27
27
|
|
|
28
|
+
var fullRowsSetKey = 'fullRowsSetKey';
|
|
29
|
+
var allEnableKeys = 'allEnableKeys';
|
|
30
|
+
var selectValueSetKey = 'selectValueSetKey';
|
|
31
|
+
|
|
28
32
|
function multiSelect() {
|
|
29
33
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
34
|
return function multiSelectStep(pipeline) {
|
|
@@ -55,10 +59,9 @@ function multiSelect() {
|
|
|
55
59
|
action: action
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
|
-
|
|
59
|
-
var dataSource = pipeline.getDataSource();
|
|
60
62
|
/** dataSource 中包含的所有 keys */
|
|
61
63
|
|
|
64
|
+
|
|
62
65
|
var fullKeySet = new _set.default();
|
|
63
66
|
/** 所有有效的 keys(disable 状态为 false) */
|
|
64
67
|
|
|
@@ -67,7 +70,7 @@ function multiSelect() {
|
|
|
67
70
|
var isAllChecked = set.size !== 0; // 当前不存在选中则默认为false
|
|
68
71
|
|
|
69
72
|
var isAnyChecked = false;
|
|
70
|
-
var flatDataSource = (0, _utils.collectNodes)(
|
|
73
|
+
var flatDataSource = (0, _utils.collectNodes)(pipeline.getDataSource());
|
|
71
74
|
flatDataSource.forEach(function (row, rowIndex) {
|
|
72
75
|
var rowKey = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
73
76
|
|
|
@@ -96,6 +99,8 @@ function multiSelect() {
|
|
|
96
99
|
checked: isAllChecked,
|
|
97
100
|
indeterminate: !isAllChecked && isAnyChecked,
|
|
98
101
|
onChange: function onChange(_) {
|
|
102
|
+
var allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
103
|
+
|
|
99
104
|
if (isAllChecked) {
|
|
100
105
|
_onChange(_others.arrayUtils.diff(value, allKeys), '', allKeys, 'uncheck-all');
|
|
101
106
|
} else {
|
|
@@ -117,9 +122,11 @@ function multiSelect() {
|
|
|
117
122
|
|
|
118
123
|
var checkboxCellProps = {};
|
|
119
124
|
var preCellProps = (_b = (_a = opts.checkboxColumn) === null || _a === void 0 ? void 0 : _a.getCellProps) === null || _b === void 0 ? void 0 : _b.call(_a, value, row, rowIndex);
|
|
125
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _set.default();
|
|
126
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _set.default();
|
|
120
127
|
|
|
121
|
-
if (
|
|
122
|
-
var prevChecked =
|
|
128
|
+
if (fullRowsSet.has(rowKey) && clickArea === 'cell') {
|
|
129
|
+
var prevChecked = selectValueSet.has(rowKey);
|
|
123
130
|
var disabled = isDisabled(row, rowIndex);
|
|
124
131
|
checkboxCellProps = {
|
|
125
132
|
style: {
|
|
@@ -144,7 +151,8 @@ function multiSelect() {
|
|
|
144
151
|
|
|
145
152
|
var key = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
146
153
|
|
|
147
|
-
var
|
|
154
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _set.default();
|
|
155
|
+
var checked = selectValueSet.has(key);
|
|
148
156
|
return /*#__PURE__*/_react.default.createElement(Checkbox, {
|
|
149
157
|
checked: checked,
|
|
150
158
|
disabled: isDisabled(row, rowIndex),
|
|
@@ -183,7 +191,9 @@ function multiSelect() {
|
|
|
183
191
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
184
192
|
var rowKey = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
185
193
|
|
|
186
|
-
|
|
194
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _set.default();
|
|
195
|
+
|
|
196
|
+
if (!fullRowsSet.has(rowKey)) {
|
|
187
197
|
// rowKey 不在 fullKeySet 中说明这一行是在 multiSelect 之后才生成的,multiSelect 不对之后生成的行进行处理
|
|
188
198
|
return;
|
|
189
199
|
}
|
|
@@ -191,7 +201,8 @@ function multiSelect() {
|
|
|
191
201
|
var style = {};
|
|
192
202
|
var className;
|
|
193
203
|
var onClick;
|
|
194
|
-
var
|
|
204
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _set.default();
|
|
205
|
+
var checked = selectValueSet.has(rowKey);
|
|
195
206
|
|
|
196
207
|
if (opts.highlightRowWhenSelected && checked) {
|
|
197
208
|
className = 'highlight';
|
|
@@ -218,22 +229,32 @@ function multiSelect() {
|
|
|
218
229
|
style: style,
|
|
219
230
|
onClick: onClick
|
|
220
231
|
};
|
|
221
|
-
});
|
|
232
|
+
}); // 只保留一份到pipeline, 避免行数据过多时内容被握住
|
|
233
|
+
|
|
234
|
+
pipeline.setFeatureOptions(fullRowsSetKey, fullKeySet);
|
|
235
|
+
pipeline.setFeatureOptions(allEnableKeys, allKeys);
|
|
236
|
+
pipeline.setFeatureOptions(selectValueSetKey, set);
|
|
237
|
+
fullKeySet = null;
|
|
238
|
+
allKeys = null;
|
|
239
|
+
set = null;
|
|
222
240
|
return pipeline;
|
|
223
241
|
|
|
224
242
|
function onCheckboxChange(prevChecked, key, batch) {
|
|
225
243
|
var batchKeys = [key];
|
|
226
244
|
|
|
227
245
|
if (batch && lastKey) {
|
|
228
|
-
var
|
|
229
|
-
|
|
246
|
+
var _allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
247
|
+
|
|
248
|
+
var lastIdx = _allKeys.indexOf(lastKey);
|
|
249
|
+
|
|
250
|
+
var cntIdx = _allKeys.indexOf(key);
|
|
230
251
|
|
|
231
252
|
var _ref = lastIdx < cntIdx ? [lastIdx, cntIdx] : [cntIdx, lastIdx],
|
|
232
253
|
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
233
254
|
start = _ref2[0],
|
|
234
255
|
end = _ref2[1];
|
|
235
256
|
|
|
236
|
-
batchKeys = (0, _slice.default)(
|
|
257
|
+
batchKeys = (0, _slice.default)(_allKeys).call(_allKeys, start, end + 1);
|
|
237
258
|
}
|
|
238
259
|
|
|
239
260
|
if (prevChecked) {
|
|
@@ -105,7 +105,7 @@ function treeMode() {
|
|
|
105
105
|
return pipeline.getFeatureOptions('lastTreeMode');
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey)
|
|
108
|
+
pipeline.setFeatureOptions('lastOpenKeys', pipeline.getStateAtKey(stateKey));
|
|
109
109
|
var result = [];
|
|
110
110
|
dfs(input, 0);
|
|
111
111
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kdcloudjs/table",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1-canary.1",
|
|
4
4
|
"description": "金蝶 react table 组件",
|
|
5
5
|
"title": "table",
|
|
6
6
|
"keywords": [
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"test:update": "jest --config .jest.js --cache=false -u",
|
|
55
55
|
"test:ci": "jest --config .jest.js --coverage --ci --update-snapshot",
|
|
56
56
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --skip-unstable",
|
|
57
|
-
"pub": "npm run build && cross-env PUB_ENV=pub np --no-cleanup --no-tests",
|
|
58
|
-
"pub:
|
|
57
|
+
"pub": "npm run test:all && npm run build && cross-env PUB_ENV=pub np --no-cleanup --no-tests",
|
|
58
|
+
"pub:canary": "npm run build && cross-env PUB_ENV=pub np --no-cleanup --anyBranch --no-tests --tag=canary",
|
|
59
59
|
"new": "node scripts/create-component.js",
|
|
60
60
|
"kd-ui": "npm install @kingdee-ui/kui --registry http://npm.kingdee.com/"
|
|
61
61
|
},
|