linkmore-design 1.1.25-beta.1 → 1.1.25-beta.2
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/LmTable/hooks/useDndItems.d.ts +2 -2
- package/dist/LmTable/util.d.ts +1 -1
- package/dist/index.umd.js +102 -51
- package/dist/index.umd.min.js +5 -5
- package/es/LmTable/Table.js +34 -21
- package/es/LmTable/components/HeaderCol.js +5 -2
- package/es/LmTable/hooks/useDndItems.d.ts +2 -2
- package/es/LmTable/hooks/useDndItems.js +58 -27
- package/es/LmTable/util.js +6 -1
- package/lib/LmTable/Table.js +34 -21
- package/lib/LmTable/components/HeaderCol.js +5 -2
- package/lib/LmTable/hooks/useDndItems.d.ts +2 -2
- package/lib/LmTable/hooks/useDndItems.js +58 -27
- package/lib/LmTable/util.js +6 -1
- package/package.json +1 -1
package/es/LmTable/Table.js
CHANGED
|
@@ -34,7 +34,7 @@ var _useGroupDataSource3 = _interopRequireDefault(require("./hooks/useGroupDataS
|
|
|
34
34
|
var _useDndItems2 = _interopRequireDefault(require("./hooks/useDndItems"));
|
|
35
35
|
var _HeaderCol = _interopRequireDefault(require("./components/HeaderCol"));
|
|
36
36
|
var _index = require("./common/index");
|
|
37
|
-
var _excluded = ["columns", "dataSource", "autoSize", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "dataChange", "openColGroup", "colGroupTitle", "openRowGroup", "rowGroupTitle", "groupWidth", "onGroupChange", "emptyProps"],
|
|
37
|
+
var _excluded = ["columns", "dataSource", "autoSize", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "dataChange", "openColGroup", "colGroupTitle", "openRowGroup", "rowGroupTitle", "groupWidth", "groupRowKeys", "groupColKeys", "onGroupChange", "emptyProps"],
|
|
38
38
|
_excluded2 = ["className", "style"],
|
|
39
39
|
_excluded3 = ["onResize", "width", "dataIndex", "onResizeStop"];
|
|
40
40
|
var Summary = _proTable.default.Summary;
|
|
@@ -109,10 +109,15 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
109
109
|
openRowGroup = props.openRowGroup,
|
|
110
110
|
rowGroupTitle = props.rowGroupTitle,
|
|
111
111
|
groupWidth = props.groupWidth,
|
|
112
|
+
customizeGroupRowKeys = props.groupRowKeys,
|
|
113
|
+
customizeGroupColKeys = props.groupColKeys,
|
|
112
114
|
_props$onGroupChange = props.onGroupChange,
|
|
113
115
|
onGroupChange = _props$onGroupChange === void 0 ? function () {} : _props$onGroupChange,
|
|
114
116
|
emptyProps = props.emptyProps,
|
|
115
117
|
resetProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
118
|
+
if (!Array.isArray(customizeColumns) || !customizeColumns.length) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
116
121
|
var _resetProps$rowKey = resetProps.rowKey,
|
|
117
122
|
rowKey = _resetProps$rowKey === void 0 ? 'id' : _resetProps$rowKey;
|
|
118
123
|
var _React$useContext = _react.default.useContext(ConfigContext),
|
|
@@ -135,8 +140,12 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
135
140
|
useActiveKey = _useState2[0],
|
|
136
141
|
setActiveKey = _useState2[1]; // 行选中
|
|
137
142
|
var tableWarpRef = (0, _react.useRef)(null);
|
|
143
|
+
/** 记录最原始数据 */
|
|
138
144
|
var dataSourceRef = (0, _react.useRef)(null);
|
|
145
|
+
dataSourceRef.current = customizeDataSource;
|
|
139
146
|
var columnsRef = (0, _react.useRef)(null);
|
|
147
|
+
columnsRef.current = customizeColumns;
|
|
148
|
+
|
|
140
149
|
/** 右键的ref */
|
|
141
150
|
var contentMenuRef = (0, _react.useRef)(null);
|
|
142
151
|
/** 当前展开的列 */
|
|
@@ -154,7 +163,9 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
154
163
|
openColGroup: openColGroup,
|
|
155
164
|
openRowGroup: openRowGroup,
|
|
156
165
|
colSortOpen: colSortOpen,
|
|
157
|
-
filterChange: filterChange
|
|
166
|
+
filterChange: filterChange,
|
|
167
|
+
customizeGroupRowKeys: customizeGroupRowKeys,
|
|
168
|
+
customizeGroupColKeys: customizeGroupColKeys
|
|
158
169
|
}),
|
|
159
170
|
dndColumns = _useDndItems.dndColumns,
|
|
160
171
|
items = _useDndItems.items,
|
|
@@ -163,14 +174,6 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
163
174
|
updateItems = _useDndItems.updateItems;
|
|
164
175
|
onGroupChange && onGroupChange(groupRowKeys, groupColKeys);
|
|
165
176
|
|
|
166
|
-
/** 记录最原始数据 */
|
|
167
|
-
(0, _react.useEffect)(function () {
|
|
168
|
-
dataSourceRef.current = customizeDataSource;
|
|
169
|
-
}, [customizeDataSource]);
|
|
170
|
-
(0, _react.useEffect)(function () {
|
|
171
|
-
columnsRef.current = customizeColumns;
|
|
172
|
-
}, [customizeColumns]);
|
|
173
|
-
|
|
174
177
|
/** 行分组 */
|
|
175
178
|
var _useGroupDataSource = (0, _useGroupDataSource3.default)({
|
|
176
179
|
groupRowKeys: groupRowKeys,
|
|
@@ -187,8 +190,8 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
187
190
|
columns: dndColumns
|
|
188
191
|
};
|
|
189
192
|
}
|
|
190
|
-
return (0, _util.transformWithColGroup)(dndColumns, groupDataSource, groupColKeys);
|
|
191
|
-
}, [dndColumns, groupDataSource, groupColKeys]),
|
|
193
|
+
return (0, _util.transformWithColGroup)(dndColumns, groupDataSource, groupColKeys, groupRowKeys);
|
|
194
|
+
}, [dndColumns, groupDataSource, groupColKeys, groupRowKeys]),
|
|
192
195
|
columns = _useMemo.columns,
|
|
193
196
|
dataSource = _useMemo.dataSource;
|
|
194
197
|
(0, _react.useEffect)(function () {
|
|
@@ -859,21 +862,23 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
859
862
|
var resetColumns = (0, _react.useCallback)(function () {
|
|
860
863
|
var colIndex = 0;
|
|
861
864
|
var traverseColumns = function traverseColumns(columns) {
|
|
862
|
-
|
|
865
|
+
var _loop = function _loop(_i) {
|
|
866
|
+
var col = columns[_i];
|
|
863
867
|
if (col.show === false) {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
if (col.children && col.children.length) {
|
|
868
|
+
columns.splice(_i, 1);
|
|
869
|
+
_i -= 1;
|
|
870
|
+
} else if (col.children && col.children.length) {
|
|
867
871
|
traverseColumns(col.children);
|
|
868
|
-
return;
|
|
869
872
|
} else {
|
|
870
873
|
// $_ 开头表示私有属性
|
|
871
874
|
col.$_colIndex = colIndex;
|
|
875
|
+
// eslint-disable-next-line no-loop-func
|
|
872
876
|
col.onHeaderCell = function (column) {
|
|
877
|
+
i = _i;
|
|
873
878
|
return resizeable ? {
|
|
874
879
|
width: column.width,
|
|
875
880
|
dataIndex: column.dataIndex,
|
|
876
|
-
onResize: handleResize(
|
|
881
|
+
onResize: handleResize(_i),
|
|
877
882
|
onResizeStop: endResize
|
|
878
883
|
} : {
|
|
879
884
|
width: column.width,
|
|
@@ -882,6 +887,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
882
887
|
};
|
|
883
888
|
if (openSheet) {
|
|
884
889
|
col.onCell = function (record, rowIndex) {
|
|
890
|
+
i = _i;
|
|
885
891
|
return {
|
|
886
892
|
record: record,
|
|
887
893
|
rowKey: rowKey,
|
|
@@ -900,9 +906,13 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
900
906
|
};
|
|
901
907
|
};
|
|
902
908
|
}
|
|
909
|
+
colIndex += 1;
|
|
903
910
|
}
|
|
904
|
-
|
|
905
|
-
}
|
|
911
|
+
i = _i;
|
|
912
|
+
};
|
|
913
|
+
for (var i = 0; i < columns.length; i += 1) {
|
|
914
|
+
_loop(i);
|
|
915
|
+
}
|
|
906
916
|
};
|
|
907
917
|
var innerColumns = (0, _lodash.cloneDeep)(useColumns.filter(function (item) {
|
|
908
918
|
return item.show !== false;
|
|
@@ -1177,7 +1187,10 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1177
1187
|
}
|
|
1178
1188
|
}, /*#__PURE__*/_react.default.createElement("th", restProps, /*#__PURE__*/_react.default.createElement(_HeaderCol.default, (0, _extends2.default)({
|
|
1179
1189
|
column: column
|
|
1180
|
-
}, props
|
|
1190
|
+
}, props, {
|
|
1191
|
+
openRowGroup: openRowGroup,
|
|
1192
|
+
openColGroup: openColGroup
|
|
1193
|
+
}))));
|
|
1181
1194
|
};
|
|
1182
1195
|
var colDraggableContainer = (0, _react.useCallback)(function (_ref4) {
|
|
1183
1196
|
var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref4), _ref4));
|
|
@@ -12,7 +12,9 @@ var _utilities = require("@dnd-kit/utilities");
|
|
|
12
12
|
var _Handle = _interopRequireDefault(require("./Item/components/Handle"));
|
|
13
13
|
function HeaderCellContent(props) {
|
|
14
14
|
var column = props.column,
|
|
15
|
-
children = props.children
|
|
15
|
+
children = props.children,
|
|
16
|
+
openRowGroup = props.openRowGroup,
|
|
17
|
+
openColGroup = props.openColGroup;
|
|
16
18
|
var rowGroup = column.rowGroup,
|
|
17
19
|
colGroup = column.colGroup,
|
|
18
20
|
_column$title = column.title,
|
|
@@ -33,6 +35,7 @@ function HeaderCellContent(props) {
|
|
|
33
35
|
touchAction: 'none',
|
|
34
36
|
display: 'flex'
|
|
35
37
|
};
|
|
38
|
+
var isShow = openRowGroup && rowGroup || openColGroup && colGroup;
|
|
36
39
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
40
|
style: {
|
|
38
41
|
display: 'flex',
|
|
@@ -42,7 +45,7 @@ function HeaderCellContent(props) {
|
|
|
42
45
|
style: {
|
|
43
46
|
flex: 1
|
|
44
47
|
}
|
|
45
|
-
}, children),
|
|
48
|
+
}, children), isShow && /*#__PURE__*/_react.default.createElement(_Handle.default, (0, _extends2.default)({
|
|
46
49
|
style: style,
|
|
47
50
|
ref: setNodeRef
|
|
48
51
|
}, attributes, listeners)));
|
|
@@ -6,8 +6,8 @@ interface IdndItems {
|
|
|
6
6
|
declare function useDndItems(props: any): {
|
|
7
7
|
dndColumns: any;
|
|
8
8
|
items: IdndItems;
|
|
9
|
-
groupRowKeys: any
|
|
10
|
-
groupColKeys: any
|
|
9
|
+
groupRowKeys: any;
|
|
10
|
+
groupColKeys: any;
|
|
11
11
|
updateItems: (value: IdndItems, resume: string) => void;
|
|
12
12
|
};
|
|
13
13
|
export default useDndItems;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import { useState, useEffect } from 'react';
|
|
3
4
|
import { treeFind } from '../common/index';
|
|
4
5
|
function del(arr, target) {
|
|
@@ -12,39 +13,55 @@ function del(arr, target) {
|
|
|
12
13
|
arr.splice(index, 1);
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
|
-
function getSortInsert(
|
|
16
|
+
function getSortInsert(tableHeader, value, _ref) {
|
|
16
17
|
var columns = _ref.columns;
|
|
17
|
-
if (!
|
|
18
|
+
if (!tableHeader) {
|
|
18
19
|
return [];
|
|
19
20
|
}
|
|
20
21
|
var arr = new Array(columns.length);
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
tableHeader.push(value);
|
|
23
|
+
tableHeader.forEach(function (val) {
|
|
23
24
|
var index = columns.findIndex(function (item) {
|
|
24
25
|
return item.title === val;
|
|
25
26
|
});
|
|
27
|
+
columns[index].show = true;
|
|
26
28
|
arr.splice(index, 0, val);
|
|
27
29
|
});
|
|
28
30
|
return arr.filter(Boolean);
|
|
29
31
|
}
|
|
30
|
-
function getSortDndColumns(
|
|
32
|
+
function getSortDndColumns(value, _ref2) {
|
|
31
33
|
var columns = _ref2.columns;
|
|
32
|
-
|
|
34
|
+
var tableHeader = value.tableHeader;
|
|
35
|
+
var hiddenArr = [].concat(_toConsumableArray(value.row), _toConsumableArray(value.col)) || [];
|
|
36
|
+
if (!tableHeader || !tableHeader.length) {
|
|
33
37
|
return [];
|
|
34
38
|
}
|
|
35
39
|
var result = [];
|
|
36
|
-
|
|
40
|
+
var _loop = function _loop(i) {
|
|
37
41
|
var item = columns.find(function (item) {
|
|
38
|
-
return item.title ===
|
|
42
|
+
return item.title === tableHeader[i];
|
|
39
43
|
});
|
|
40
44
|
if (item) {
|
|
45
|
+
item.order = i;
|
|
41
46
|
result.push(item);
|
|
42
47
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
};
|
|
49
|
+
for (var i = 0; i < tableHeader.length; i++) {
|
|
50
|
+
_loop(i);
|
|
51
|
+
}
|
|
52
|
+
var _loop2 = function _loop2(_i) {
|
|
53
|
+
var item = columns.find(function (item) {
|
|
54
|
+
return item.title === hiddenArr[_i];
|
|
55
|
+
});
|
|
56
|
+
if (item) {
|
|
57
|
+
item.show = false;
|
|
58
|
+
result.push(item);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
for (var _i = 0; _i < hiddenArr.length; _i++) {
|
|
62
|
+
_loop2(_i);
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
48
65
|
}
|
|
49
66
|
function getDataIndexForTitle(row, columns) {
|
|
50
67
|
if (!row) {
|
|
@@ -64,40 +81,53 @@ function useDndItems(props) {
|
|
|
64
81
|
colSortOpen = props.colSortOpen,
|
|
65
82
|
filterChange = props.filterChange,
|
|
66
83
|
openRowGroup = props.openRowGroup,
|
|
67
|
-
openColGroup = props.openColGroup
|
|
84
|
+
openColGroup = props.openColGroup,
|
|
85
|
+
customizeGroupRowKeys = props.customizeGroupRowKeys,
|
|
86
|
+
customizeGroupColKeys = props.customizeGroupColKeys;
|
|
68
87
|
var _useState = useState(columns),
|
|
69
88
|
_useState2 = _slicedToArray(_useState, 2),
|
|
70
89
|
dndColumns = _useState2[0],
|
|
71
90
|
setDndColumns = _useState2[1];
|
|
72
|
-
var _useState3 = useState([]),
|
|
91
|
+
var _useState3 = useState(customizeGroupRowKeys || []),
|
|
73
92
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
74
93
|
groupRowKeys = _useState4[0],
|
|
75
94
|
setGroupRowKeys = _useState4[1];
|
|
76
|
-
var _useState5 = useState([]),
|
|
95
|
+
var _useState5 = useState(customizeGroupColKeys || []),
|
|
77
96
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
78
97
|
groupColKeys = _useState6[0],
|
|
79
98
|
setGroupColKeys = _useState6[1];
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
setGroupRowKeys(customizeGroupRowKeys);
|
|
101
|
+
setGroupColKeys(customizeGroupColKeys);
|
|
102
|
+
}, [customizeGroupRowKeys, customizeGroupColKeys]);
|
|
80
103
|
// 初始化
|
|
81
|
-
var defaultItems = {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
defaultItems.col = [];
|
|
87
|
-
}
|
|
104
|
+
var defaultItems = {
|
|
105
|
+
row: [],
|
|
106
|
+
col: [],
|
|
107
|
+
tableHeader: []
|
|
108
|
+
};
|
|
88
109
|
if (openColGroup || openRowGroup || colSortOpen) {
|
|
89
|
-
var tableHeader = [];
|
|
90
110
|
treeFind(columns, function (node) {
|
|
91
|
-
|
|
111
|
+
if (groupRowKeys.includes(node.dataIndex)) {
|
|
112
|
+
defaultItems.row.push(node.title);
|
|
113
|
+
} else if (groupColKeys.includes(node.dataIndex)) {
|
|
114
|
+
defaultItems.col.push(node.title);
|
|
115
|
+
} else {
|
|
116
|
+
defaultItems.tableHeader.push(node.title);
|
|
117
|
+
}
|
|
92
118
|
return false;
|
|
93
119
|
});
|
|
94
|
-
defaultItems.tableHeader = tableHeader;
|
|
95
120
|
}
|
|
96
121
|
var _useState7 = useState(defaultItems),
|
|
97
122
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
98
123
|
items = _useState8[0],
|
|
99
124
|
setItems = _useState8[1];
|
|
100
125
|
useEffect(function () {
|
|
126
|
+
columns.forEach(function (c) {
|
|
127
|
+
if (customizeGroupRowKeys.includes(c.dataIndex) || customizeGroupColKeys.includes(c.dataIndex)) {
|
|
128
|
+
c.show = false;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
101
131
|
setDndColumns(columns);
|
|
102
132
|
setItems(defaultItems);
|
|
103
133
|
}, [columns]);
|
|
@@ -113,6 +143,7 @@ function useDndItems(props) {
|
|
|
113
143
|
columns: columns
|
|
114
144
|
});
|
|
115
145
|
}
|
|
146
|
+
// 列分组进行覆盖,只允许存在一个
|
|
116
147
|
if (value.col.length >= 2) {
|
|
117
148
|
value.tableHeader = getSortInsert(value.tableHeader, items.col[0], {
|
|
118
149
|
columns: columns
|
|
@@ -124,7 +155,7 @@ function useDndItems(props) {
|
|
|
124
155
|
setItems(value);
|
|
125
156
|
setGroupRowKeys(getDataIndexForTitle(value.row, columns));
|
|
126
157
|
setGroupColKeys(getDataIndexForTitle(value.col, columns));
|
|
127
|
-
var newColumns = getSortDndColumns(value
|
|
158
|
+
var newColumns = getSortDndColumns(value, {
|
|
128
159
|
columns: columns
|
|
129
160
|
});
|
|
130
161
|
setDndColumns(newColumns);
|
package/es/LmTable/util.js
CHANGED
|
@@ -64,13 +64,18 @@ function dataGroup(data, key) {
|
|
|
64
64
|
* @param groupColKeys 列分组的keys
|
|
65
65
|
* @returns
|
|
66
66
|
*/
|
|
67
|
-
function transformWithColGroup(columns, dataSource, groupColKeys) {
|
|
67
|
+
function transformWithColGroup(columns, dataSource, groupColKeys, groupRowKeys) {
|
|
68
68
|
if (!Array.isArray(groupColKeys) || !groupColKeys.length) {
|
|
69
69
|
return {
|
|
70
70
|
columns: columns,
|
|
71
71
|
dataSource: dataSource
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
columns.forEach(function (c) {
|
|
75
|
+
if (groupRowKeys.includes(c.dataIndex)) {
|
|
76
|
+
c.show = false;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
74
79
|
var columnsCopy = _lodash.default.cloneDeep(columns);
|
|
75
80
|
var dataSourceCopy = _lodash.default.cloneDeep(dataSource);
|
|
76
81
|
|
package/lib/LmTable/Table.js
CHANGED
|
@@ -34,7 +34,7 @@ var _useGroupDataSource3 = _interopRequireDefault(require("./hooks/useGroupDataS
|
|
|
34
34
|
var _useDndItems2 = _interopRequireDefault(require("./hooks/useDndItems"));
|
|
35
35
|
var _HeaderCol = _interopRequireDefault(require("./components/HeaderCol"));
|
|
36
36
|
var _index = require("./common/index");
|
|
37
|
-
var _excluded = ["columns", "dataSource", "autoSize", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "dataChange", "openColGroup", "colGroupTitle", "openRowGroup", "rowGroupTitle", "groupWidth", "onGroupChange", "emptyProps"],
|
|
37
|
+
var _excluded = ["columns", "dataSource", "autoSize", "rowClick", "onDoubleClick", "checkConfig", "summary", "pagination", "hiddenPage", "loading", "virtual", "sortOpen", "colSortOpen", "resizeable", "customCheck", "components", "rowSelection", "columnsState", "onChange", "filterChange", "tableRowType", "size", "openSheet", "editSheet", "dataChange", "openColGroup", "colGroupTitle", "openRowGroup", "rowGroupTitle", "groupWidth", "groupRowKeys", "groupColKeys", "onGroupChange", "emptyProps"],
|
|
38
38
|
_excluded2 = ["className", "style"],
|
|
39
39
|
_excluded3 = ["onResize", "width", "dataIndex", "onResizeStop"];
|
|
40
40
|
var Summary = _proTable.default.Summary;
|
|
@@ -109,10 +109,15 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
109
109
|
openRowGroup = props.openRowGroup,
|
|
110
110
|
rowGroupTitle = props.rowGroupTitle,
|
|
111
111
|
groupWidth = props.groupWidth,
|
|
112
|
+
customizeGroupRowKeys = props.groupRowKeys,
|
|
113
|
+
customizeGroupColKeys = props.groupColKeys,
|
|
112
114
|
_props$onGroupChange = props.onGroupChange,
|
|
113
115
|
onGroupChange = _props$onGroupChange === void 0 ? function () {} : _props$onGroupChange,
|
|
114
116
|
emptyProps = props.emptyProps,
|
|
115
117
|
resetProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
118
|
+
if (!Array.isArray(customizeColumns) || !customizeColumns.length) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
116
121
|
var _resetProps$rowKey = resetProps.rowKey,
|
|
117
122
|
rowKey = _resetProps$rowKey === void 0 ? 'id' : _resetProps$rowKey;
|
|
118
123
|
var _React$useContext = _react.default.useContext(ConfigContext),
|
|
@@ -135,8 +140,12 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
135
140
|
useActiveKey = _useState2[0],
|
|
136
141
|
setActiveKey = _useState2[1]; // 行选中
|
|
137
142
|
var tableWarpRef = (0, _react.useRef)(null);
|
|
143
|
+
/** 记录最原始数据 */
|
|
138
144
|
var dataSourceRef = (0, _react.useRef)(null);
|
|
145
|
+
dataSourceRef.current = customizeDataSource;
|
|
139
146
|
var columnsRef = (0, _react.useRef)(null);
|
|
147
|
+
columnsRef.current = customizeColumns;
|
|
148
|
+
|
|
140
149
|
/** 右键的ref */
|
|
141
150
|
var contentMenuRef = (0, _react.useRef)(null);
|
|
142
151
|
/** 当前展开的列 */
|
|
@@ -154,7 +163,9 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
154
163
|
openColGroup: openColGroup,
|
|
155
164
|
openRowGroup: openRowGroup,
|
|
156
165
|
colSortOpen: colSortOpen,
|
|
157
|
-
filterChange: filterChange
|
|
166
|
+
filterChange: filterChange,
|
|
167
|
+
customizeGroupRowKeys: customizeGroupRowKeys,
|
|
168
|
+
customizeGroupColKeys: customizeGroupColKeys
|
|
158
169
|
}),
|
|
159
170
|
dndColumns = _useDndItems.dndColumns,
|
|
160
171
|
items = _useDndItems.items,
|
|
@@ -163,14 +174,6 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
163
174
|
updateItems = _useDndItems.updateItems;
|
|
164
175
|
onGroupChange && onGroupChange(groupRowKeys, groupColKeys);
|
|
165
176
|
|
|
166
|
-
/** 记录最原始数据 */
|
|
167
|
-
(0, _react.useEffect)(function () {
|
|
168
|
-
dataSourceRef.current = customizeDataSource;
|
|
169
|
-
}, [customizeDataSource]);
|
|
170
|
-
(0, _react.useEffect)(function () {
|
|
171
|
-
columnsRef.current = customizeColumns;
|
|
172
|
-
}, [customizeColumns]);
|
|
173
|
-
|
|
174
177
|
/** 行分组 */
|
|
175
178
|
var _useGroupDataSource = (0, _useGroupDataSource3.default)({
|
|
176
179
|
groupRowKeys: groupRowKeys,
|
|
@@ -187,8 +190,8 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
187
190
|
columns: dndColumns
|
|
188
191
|
};
|
|
189
192
|
}
|
|
190
|
-
return (0, _util.transformWithColGroup)(dndColumns, groupDataSource, groupColKeys);
|
|
191
|
-
}, [dndColumns, groupDataSource, groupColKeys]),
|
|
193
|
+
return (0, _util.transformWithColGroup)(dndColumns, groupDataSource, groupColKeys, groupRowKeys);
|
|
194
|
+
}, [dndColumns, groupDataSource, groupColKeys, groupRowKeys]),
|
|
192
195
|
columns = _useMemo.columns,
|
|
193
196
|
dataSource = _useMemo.dataSource;
|
|
194
197
|
(0, _react.useEffect)(function () {
|
|
@@ -859,21 +862,23 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
859
862
|
var resetColumns = (0, _react.useCallback)(function () {
|
|
860
863
|
var colIndex = 0;
|
|
861
864
|
var traverseColumns = function traverseColumns(columns) {
|
|
862
|
-
|
|
865
|
+
var _loop = function _loop(_i) {
|
|
866
|
+
var col = columns[_i];
|
|
863
867
|
if (col.show === false) {
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
if (col.children && col.children.length) {
|
|
868
|
+
columns.splice(_i, 1);
|
|
869
|
+
_i -= 1;
|
|
870
|
+
} else if (col.children && col.children.length) {
|
|
867
871
|
traverseColumns(col.children);
|
|
868
|
-
return;
|
|
869
872
|
} else {
|
|
870
873
|
// $_ 开头表示私有属性
|
|
871
874
|
col.$_colIndex = colIndex;
|
|
875
|
+
// eslint-disable-next-line no-loop-func
|
|
872
876
|
col.onHeaderCell = function (column) {
|
|
877
|
+
i = _i;
|
|
873
878
|
return resizeable ? {
|
|
874
879
|
width: column.width,
|
|
875
880
|
dataIndex: column.dataIndex,
|
|
876
|
-
onResize: handleResize(
|
|
881
|
+
onResize: handleResize(_i),
|
|
877
882
|
onResizeStop: endResize
|
|
878
883
|
} : {
|
|
879
884
|
width: column.width,
|
|
@@ -882,6 +887,7 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
882
887
|
};
|
|
883
888
|
if (openSheet) {
|
|
884
889
|
col.onCell = function (record, rowIndex) {
|
|
890
|
+
i = _i;
|
|
885
891
|
return {
|
|
886
892
|
record: record,
|
|
887
893
|
rowKey: rowKey,
|
|
@@ -900,9 +906,13 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
900
906
|
};
|
|
901
907
|
};
|
|
902
908
|
}
|
|
909
|
+
colIndex += 1;
|
|
903
910
|
}
|
|
904
|
-
|
|
905
|
-
}
|
|
911
|
+
i = _i;
|
|
912
|
+
};
|
|
913
|
+
for (var i = 0; i < columns.length; i += 1) {
|
|
914
|
+
_loop(i);
|
|
915
|
+
}
|
|
906
916
|
};
|
|
907
917
|
var innerColumns = (0, _lodash.cloneDeep)(useColumns.filter(function (item) {
|
|
908
918
|
return item.show !== false;
|
|
@@ -1177,7 +1187,10 @@ var ResetTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1177
1187
|
}
|
|
1178
1188
|
}, /*#__PURE__*/_react.default.createElement("th", restProps, /*#__PURE__*/_react.default.createElement(_HeaderCol.default, (0, _extends2.default)({
|
|
1179
1189
|
column: column
|
|
1180
|
-
}, props
|
|
1190
|
+
}, props, {
|
|
1191
|
+
openRowGroup: openRowGroup,
|
|
1192
|
+
openColGroup: openColGroup
|
|
1193
|
+
}))));
|
|
1181
1194
|
};
|
|
1182
1195
|
var colDraggableContainer = (0, _react.useCallback)(function (_ref4) {
|
|
1183
1196
|
var props = (0, _extends2.default)({}, ((0, _objectDestructuringEmpty2.default)(_ref4), _ref4));
|
|
@@ -12,7 +12,9 @@ var _utilities = require("@dnd-kit/utilities");
|
|
|
12
12
|
var _Handle = _interopRequireDefault(require("./Item/components/Handle"));
|
|
13
13
|
function HeaderCellContent(props) {
|
|
14
14
|
var column = props.column,
|
|
15
|
-
children = props.children
|
|
15
|
+
children = props.children,
|
|
16
|
+
openRowGroup = props.openRowGroup,
|
|
17
|
+
openColGroup = props.openColGroup;
|
|
16
18
|
var rowGroup = column.rowGroup,
|
|
17
19
|
colGroup = column.colGroup,
|
|
18
20
|
_column$title = column.title,
|
|
@@ -33,6 +35,7 @@ function HeaderCellContent(props) {
|
|
|
33
35
|
touchAction: 'none',
|
|
34
36
|
display: 'flex'
|
|
35
37
|
};
|
|
38
|
+
var isShow = openRowGroup && rowGroup || openColGroup && colGroup;
|
|
36
39
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
37
40
|
style: {
|
|
38
41
|
display: 'flex',
|
|
@@ -42,7 +45,7 @@ function HeaderCellContent(props) {
|
|
|
42
45
|
style: {
|
|
43
46
|
flex: 1
|
|
44
47
|
}
|
|
45
|
-
}, children),
|
|
48
|
+
}, children), isShow && /*#__PURE__*/_react.default.createElement(_Handle.default, (0, _extends2.default)({
|
|
46
49
|
style: style,
|
|
47
50
|
ref: setNodeRef
|
|
48
51
|
}, attributes, listeners)));
|
|
@@ -6,8 +6,8 @@ interface IdndItems {
|
|
|
6
6
|
declare function useDndItems(props: any): {
|
|
7
7
|
dndColumns: any;
|
|
8
8
|
items: IdndItems;
|
|
9
|
-
groupRowKeys: any
|
|
10
|
-
groupColKeys: any
|
|
9
|
+
groupRowKeys: any;
|
|
10
|
+
groupColKeys: any;
|
|
11
11
|
updateItems: (value: IdndItems, resume: string) => void;
|
|
12
12
|
};
|
|
13
13
|
export default useDndItems;
|