@kdcloudjs/table 1.2.0-canary.1 → 1.2.0-canary.3
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 +38 -15
- package/dist/@kdcloudjs/table.js.map +1 -1
- package/dist/@kdcloudjs/table.min.css +1 -1
- package/dist/@kdcloudjs/table.min.js +3 -3
- package/dist/@kdcloudjs/table.min.js.map +1 -1
- package/es/table/common-views.js +3 -1
- package/es/table/pipeline/features/columnResizeWidth.js +3 -1
- package/es/table/pipeline/features/multiSelect.js +31 -12
- package/lib/table/common-views.js +3 -1
- package/lib/table/pipeline/features/columnResizeWidth.js +3 -1
- package/lib/table/pipeline/features/multiSelect.js +33 -12
- package/package.json +1 -1
package/es/table/common-views.js
CHANGED
|
@@ -7,7 +7,9 @@ import React from 'react';
|
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import { MenuClasses, Classes } from './base/styles';
|
|
9
9
|
export var InlineFlexCell = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n align-items: center;\n"])));
|
|
10
|
-
export var ExpansionCell = styled(
|
|
10
|
+
export var ExpansionCell = styled(function (props) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(InlineFlexCell, _extends({}, props));
|
|
12
|
+
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &.", " {\n cursor: default;\n }\n\n .expansion-icon {\n fill: #999;\n flex: 0 0 16px;\n transition: transform 200ms;\n\n &.", " {\n transform-origin: center center;\n transform: rotate(90deg);\n }\n }\n"])), Classes.leaf, Classes.expanded);
|
|
11
13
|
|
|
12
14
|
function CaretDownIcon(props) {
|
|
13
15
|
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
@@ -14,7 +14,9 @@ import { mergeCellProps, collectNodes, makeRecursiveMapper, isGroupColumn } from
|
|
|
14
14
|
import { internals } from '../../internals';
|
|
15
15
|
import { Classes } from '../../base/styles';
|
|
16
16
|
var TableHeaderCellResize = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 0;\n right: -5px;\n height: 100%;\n width: 10px;\n cursor: ew-resize;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index:1;\n\n &:after {\n content: \"\";\n position: absolute;\n display: block;\n left: calc(50% - 1px);\n width: 1px;\n height: calc(100% - 14px);\n top: 7px;\n }\n"])));
|
|
17
|
-
var TableHeaderGroupCellResize = styled(
|
|
17
|
+
var TableHeaderGroupCellResize = styled(function (props) {
|
|
18
|
+
return /*#__PURE__*/React.createElement(TableHeaderCellResize, _extends({}, props));
|
|
19
|
+
})(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &:after {\n height: 100%;\n top: 0;\n }\n"])));
|
|
18
20
|
|
|
19
21
|
function clamp(min, x, max) {
|
|
20
22
|
return Math.max(min, Math.min(max, x));
|
|
@@ -6,6 +6,9 @@ import React from 'react';
|
|
|
6
6
|
import { internals } from '../../internals';
|
|
7
7
|
import { always, arrayUtils } from '../../utils/others';
|
|
8
8
|
import { collectNodes, mergeCellProps } from '../../utils';
|
|
9
|
+
var fullRowsSetKey = 'fullRowsSetKey';
|
|
10
|
+
var allEnableKeys = 'allEnableKeys';
|
|
11
|
+
var selectValueSetKey = 'selectValueSetKey';
|
|
9
12
|
export function multiSelect() {
|
|
10
13
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11
14
|
return function multiSelectStep(pipeline) {
|
|
@@ -36,10 +39,9 @@ export function multiSelect() {
|
|
|
36
39
|
action: action
|
|
37
40
|
});
|
|
38
41
|
};
|
|
39
|
-
|
|
40
|
-
var dataSource = pipeline.getDataSource();
|
|
41
42
|
/** dataSource 中包含的所有 keys */
|
|
42
43
|
|
|
44
|
+
|
|
43
45
|
var fullKeySet = new _Set();
|
|
44
46
|
/** 所有有效的 keys(disable 状态为 false) */
|
|
45
47
|
|
|
@@ -48,7 +50,7 @@ export function multiSelect() {
|
|
|
48
50
|
var isAllChecked = set.size !== 0; // 当前不存在选中则默认为false
|
|
49
51
|
|
|
50
52
|
var isAnyChecked = false;
|
|
51
|
-
var flatDataSource = collectNodes(
|
|
53
|
+
var flatDataSource = collectNodes(pipeline.getDataSource());
|
|
52
54
|
flatDataSource.forEach(function (row, rowIndex) {
|
|
53
55
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
54
56
|
fullKeySet.add(rowKey); // 在 allKeys 中排除被禁用的 key
|
|
@@ -76,6 +78,8 @@ export function multiSelect() {
|
|
|
76
78
|
checked: isAllChecked,
|
|
77
79
|
indeterminate: !isAllChecked && isAnyChecked,
|
|
78
80
|
onChange: function onChange(_) {
|
|
81
|
+
var allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
82
|
+
|
|
79
83
|
if (isAllChecked) {
|
|
80
84
|
_onChange(arrayUtils.diff(value, allKeys), '', allKeys, 'uncheck-all');
|
|
81
85
|
} else {
|
|
@@ -96,9 +100,11 @@ export function multiSelect() {
|
|
|
96
100
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
97
101
|
var checkboxCellProps = {};
|
|
98
102
|
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);
|
|
103
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _Set();
|
|
104
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
99
105
|
|
|
100
|
-
if (
|
|
101
|
-
var prevChecked =
|
|
106
|
+
if (fullRowsSet.has(rowKey) && clickArea === 'cell') {
|
|
107
|
+
var prevChecked = selectValueSet.has(rowKey);
|
|
102
108
|
var disabled = isDisabled(row, rowIndex);
|
|
103
109
|
checkboxCellProps = {
|
|
104
110
|
style: {
|
|
@@ -122,7 +128,8 @@ export function multiSelect() {
|
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
var key = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
125
|
-
var
|
|
131
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
132
|
+
var checked = selectValueSet.has(key);
|
|
126
133
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
127
134
|
checked: checked,
|
|
128
135
|
disabled: isDisabled(row, rowIndex),
|
|
@@ -161,8 +168,9 @@ export function multiSelect() {
|
|
|
161
168
|
|
|
162
169
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
163
170
|
var rowKey = internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
171
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _Set();
|
|
164
172
|
|
|
165
|
-
if (!
|
|
173
|
+
if (!fullRowsSet.has(rowKey)) {
|
|
166
174
|
// rowKey 不在 fullKeySet 中说明这一行是在 multiSelect 之后才生成的,multiSelect 不对之后生成的行进行处理
|
|
167
175
|
return;
|
|
168
176
|
}
|
|
@@ -170,7 +178,8 @@ export function multiSelect() {
|
|
|
170
178
|
var style = {};
|
|
171
179
|
var className;
|
|
172
180
|
var onClick;
|
|
173
|
-
var
|
|
181
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _Set();
|
|
182
|
+
var checked = selectValueSet.has(rowKey);
|
|
174
183
|
|
|
175
184
|
if (opts.highlightRowWhenSelected && checked) {
|
|
176
185
|
className = 'highlight';
|
|
@@ -197,22 +206,32 @@ export function multiSelect() {
|
|
|
197
206
|
style: style,
|
|
198
207
|
onClick: onClick
|
|
199
208
|
};
|
|
200
|
-
});
|
|
209
|
+
}); // 只保留一份到pipeline, 避免行数据过多时内容被握住
|
|
210
|
+
|
|
211
|
+
pipeline.setFeatureOptions(fullRowsSetKey, fullKeySet);
|
|
212
|
+
pipeline.setFeatureOptions(allEnableKeys, allKeys);
|
|
213
|
+
pipeline.setFeatureOptions(selectValueSetKey, set);
|
|
214
|
+
fullKeySet = null;
|
|
215
|
+
allKeys = null;
|
|
216
|
+
set = null;
|
|
201
217
|
return pipeline;
|
|
202
218
|
|
|
203
219
|
function onCheckboxChange(prevChecked, key, batch) {
|
|
204
220
|
var batchKeys = [key];
|
|
205
221
|
|
|
206
222
|
if (batch && lastKey) {
|
|
207
|
-
var
|
|
208
|
-
|
|
223
|
+
var _allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
224
|
+
|
|
225
|
+
var lastIdx = _allKeys.indexOf(lastKey);
|
|
226
|
+
|
|
227
|
+
var cntIdx = _allKeys.indexOf(key);
|
|
209
228
|
|
|
210
229
|
var _ref = lastIdx < cntIdx ? [lastIdx, cntIdx] : [cntIdx, lastIdx],
|
|
211
230
|
_ref2 = _slicedToArray(_ref, 2),
|
|
212
231
|
start = _ref2[0],
|
|
213
232
|
end = _ref2[1];
|
|
214
233
|
|
|
215
|
-
batchKeys = _sliceInstanceProperty(
|
|
234
|
+
batchKeys = _sliceInstanceProperty(_allKeys).call(_allKeys, start, end + 1);
|
|
216
235
|
}
|
|
217
236
|
|
|
218
237
|
if (prevChecked) {
|
|
@@ -22,7 +22,9 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
22
22
|
var InlineFlexCell = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n align-items: center;\n"])));
|
|
23
23
|
|
|
24
24
|
exports.InlineFlexCell = InlineFlexCell;
|
|
25
|
-
var ExpansionCell = (0, _styledComponents.default)(
|
|
25
|
+
var ExpansionCell = (0, _styledComponents.default)(function (props) {
|
|
26
|
+
return /*#__PURE__*/_react.default.createElement(InlineFlexCell, (0, _extends2.default)({}, props));
|
|
27
|
+
})(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n &.", " {\n cursor: default;\n }\n\n .expansion-icon {\n fill: #999;\n flex: 0 0 16px;\n transition: transform 200ms;\n\n &.", " {\n transform-origin: center center;\n transform: rotate(90deg);\n }\n }\n"])), _styles.Classes.leaf, _styles.Classes.expanded);
|
|
26
28
|
exports.ExpansionCell = ExpansionCell;
|
|
27
29
|
|
|
28
30
|
function CaretDownIcon(props) {
|
|
@@ -46,7 +46,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
46
46
|
|
|
47
47
|
var TableHeaderCellResize = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n top: 0;\n right: -5px;\n height: 100%;\n width: 10px;\n cursor: ew-resize;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index:1;\n\n &:after {\n content: \"\";\n position: absolute;\n display: block;\n left: calc(50% - 1px);\n width: 1px;\n height: calc(100% - 14px);\n top: 7px;\n }\n"])));
|
|
48
48
|
|
|
49
|
-
var TableHeaderGroupCellResize = (0, _styledComponents.default)(
|
|
49
|
+
var TableHeaderGroupCellResize = (0, _styledComponents.default)(function (props) {
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(TableHeaderCellResize, (0, _extends2.default)({}, props));
|
|
51
|
+
})(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n &:after {\n height: 100%;\n top: 0;\n }\n"])));
|
|
50
52
|
|
|
51
53
|
function clamp(min, x, max) {
|
|
52
54
|
return Math.max(min, Math.min(max, x));
|
|
@@ -23,6 +23,10 @@ var _others = require("../../utils/others");
|
|
|
23
23
|
|
|
24
24
|
var _utils = require("../../utils");
|
|
25
25
|
|
|
26
|
+
var fullRowsSetKey = 'fullRowsSetKey';
|
|
27
|
+
var allEnableKeys = 'allEnableKeys';
|
|
28
|
+
var selectValueSetKey = 'selectValueSetKey';
|
|
29
|
+
|
|
26
30
|
function multiSelect() {
|
|
27
31
|
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
28
32
|
return function multiSelectStep(pipeline) {
|
|
@@ -53,10 +57,9 @@ function multiSelect() {
|
|
|
53
57
|
action: action
|
|
54
58
|
});
|
|
55
59
|
};
|
|
56
|
-
|
|
57
|
-
var dataSource = pipeline.getDataSource();
|
|
58
60
|
/** dataSource 中包含的所有 keys */
|
|
59
61
|
|
|
62
|
+
|
|
60
63
|
var fullKeySet = new _set.default();
|
|
61
64
|
/** 所有有效的 keys(disable 状态为 false) */
|
|
62
65
|
|
|
@@ -65,7 +68,7 @@ function multiSelect() {
|
|
|
65
68
|
var isAllChecked = set.size !== 0; // 当前不存在选中则默认为false
|
|
66
69
|
|
|
67
70
|
var isAnyChecked = false;
|
|
68
|
-
var flatDataSource = (0, _utils.collectNodes)(
|
|
71
|
+
var flatDataSource = (0, _utils.collectNodes)(pipeline.getDataSource());
|
|
69
72
|
flatDataSource.forEach(function (row, rowIndex) {
|
|
70
73
|
var rowKey = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
71
74
|
|
|
@@ -94,6 +97,8 @@ function multiSelect() {
|
|
|
94
97
|
checked: isAllChecked,
|
|
95
98
|
indeterminate: !isAllChecked && isAnyChecked,
|
|
96
99
|
onChange: function onChange(_) {
|
|
100
|
+
var allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
101
|
+
|
|
97
102
|
if (isAllChecked) {
|
|
98
103
|
_onChange(_others.arrayUtils.diff(value, allKeys), '', allKeys, 'uncheck-all');
|
|
99
104
|
} else {
|
|
@@ -115,9 +120,11 @@ function multiSelect() {
|
|
|
115
120
|
|
|
116
121
|
var checkboxCellProps = {};
|
|
117
122
|
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);
|
|
123
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _set.default();
|
|
124
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _set.default();
|
|
118
125
|
|
|
119
|
-
if (
|
|
120
|
-
var prevChecked =
|
|
126
|
+
if (fullRowsSet.has(rowKey) && clickArea === 'cell') {
|
|
127
|
+
var prevChecked = selectValueSet.has(rowKey);
|
|
121
128
|
var disabled = isDisabled(row, rowIndex);
|
|
122
129
|
checkboxCellProps = {
|
|
123
130
|
style: {
|
|
@@ -142,7 +149,8 @@ function multiSelect() {
|
|
|
142
149
|
|
|
143
150
|
var key = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
144
151
|
|
|
145
|
-
var
|
|
152
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _set.default();
|
|
153
|
+
var checked = selectValueSet.has(key);
|
|
146
154
|
return /*#__PURE__*/_react.default.createElement(Checkbox, {
|
|
147
155
|
checked: checked,
|
|
148
156
|
disabled: isDisabled(row, rowIndex),
|
|
@@ -180,7 +188,9 @@ function multiSelect() {
|
|
|
180
188
|
pipeline.appendRowPropsGetter(function (row, rowIndex) {
|
|
181
189
|
var rowKey = _internals.internals.safeGetRowKey(primaryKey, row, rowIndex);
|
|
182
190
|
|
|
183
|
-
|
|
191
|
+
var fullRowsSet = pipeline.getFeatureOptions(fullRowsSetKey) || new _set.default();
|
|
192
|
+
|
|
193
|
+
if (!fullRowsSet.has(rowKey)) {
|
|
184
194
|
// rowKey 不在 fullKeySet 中说明这一行是在 multiSelect 之后才生成的,multiSelect 不对之后生成的行进行处理
|
|
185
195
|
return;
|
|
186
196
|
}
|
|
@@ -188,7 +198,8 @@ function multiSelect() {
|
|
|
188
198
|
var style = {};
|
|
189
199
|
var className;
|
|
190
200
|
var onClick;
|
|
191
|
-
var
|
|
201
|
+
var selectValueSet = pipeline.getFeatureOptions(selectValueSetKey) || new _set.default();
|
|
202
|
+
var checked = selectValueSet.has(rowKey);
|
|
192
203
|
|
|
193
204
|
if (opts.highlightRowWhenSelected && checked) {
|
|
194
205
|
className = 'highlight';
|
|
@@ -215,22 +226,32 @@ function multiSelect() {
|
|
|
215
226
|
style: style,
|
|
216
227
|
onClick: onClick
|
|
217
228
|
};
|
|
218
|
-
});
|
|
229
|
+
}); // 只保留一份到pipeline, 避免行数据过多时内容被握住
|
|
230
|
+
|
|
231
|
+
pipeline.setFeatureOptions(fullRowsSetKey, fullKeySet);
|
|
232
|
+
pipeline.setFeatureOptions(allEnableKeys, allKeys);
|
|
233
|
+
pipeline.setFeatureOptions(selectValueSetKey, set);
|
|
234
|
+
fullKeySet = null;
|
|
235
|
+
allKeys = null;
|
|
236
|
+
set = null;
|
|
219
237
|
return pipeline;
|
|
220
238
|
|
|
221
239
|
function onCheckboxChange(prevChecked, key, batch) {
|
|
222
240
|
var batchKeys = [key];
|
|
223
241
|
|
|
224
242
|
if (batch && lastKey) {
|
|
225
|
-
var
|
|
226
|
-
|
|
243
|
+
var _allKeys = pipeline.getFeatureOptions(allEnableKeys);
|
|
244
|
+
|
|
245
|
+
var lastIdx = _allKeys.indexOf(lastKey);
|
|
246
|
+
|
|
247
|
+
var cntIdx = _allKeys.indexOf(key);
|
|
227
248
|
|
|
228
249
|
var _ref = lastIdx < cntIdx ? [lastIdx, cntIdx] : [cntIdx, lastIdx],
|
|
229
250
|
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
230
251
|
start = _ref2[0],
|
|
231
252
|
end = _ref2[1];
|
|
232
253
|
|
|
233
|
-
batchKeys = (0, _slice.default)(
|
|
254
|
+
batchKeys = (0, _slice.default)(_allKeys).call(_allKeys, start, end + 1);
|
|
234
255
|
}
|
|
235
256
|
|
|
236
257
|
if (prevChecked) {
|