linkmore-design 1.1.13-alpha.5 → 1.1.13-alpha.6
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/LmEditTable/EditTable.d.ts +1 -1
- package/dist/index.umd.js +118 -33
- package/dist/index.umd.min.js +1 -1
- package/es/LmEditTable/EditTable.d.ts +1 -1
- package/es/LmEditTable/EditTable.js +70 -21
- package/es/LmEditTable/sortableItemCol.js +38 -13
- package/es/LmEditTable/util.js +16 -5
- package/lib/LmEditTable/EditTable.d.ts +1 -1
- package/lib/LmEditTable/EditTable.js +70 -21
- package/lib/LmEditTable/sortableItemCol.js +34 -11
- package/lib/LmEditTable/util.js +15 -4
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ export interface CountdownHandle {
|
|
|
33
33
|
clearSelect: () => void;
|
|
34
34
|
customSetCheckboxRecords: (data: any[]) => void;
|
|
35
35
|
deleteRowData: (record: string | Record<string, any>) => void;
|
|
36
|
-
addRowData: (record: string | Record<string, any>,
|
|
36
|
+
addRowData: (record: string | Record<string, any>, defaultValue?: Record<string, any> | Record<string, any>[], addInChild?: boolean) => void;
|
|
37
37
|
valid: () => void;
|
|
38
38
|
}
|
|
39
39
|
interface ILmColumns extends TableColumnType<any> {
|
|
@@ -461,7 +461,16 @@ var EditableCell = function EditableCell(props) {
|
|
|
461
461
|
};
|
|
462
462
|
|
|
463
463
|
var Control = function Control(con) {
|
|
464
|
+
var _a;
|
|
465
|
+
|
|
464
466
|
var resultComponentProps = isFunction(componentProps) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps(record, col) : componentProps;
|
|
467
|
+
|
|
468
|
+
if (isFunction(componentProps) && ((_a = col === null || col === void 0 ? void 0 : col.newOptions) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
469
|
+
resultComponentProps = Object.assign(Object.assign({}, resultComponentProps), {
|
|
470
|
+
options: col === null || col === void 0 ? void 0 : col.newOptions
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
465
474
|
var clearAttrComponentProps = omit(resultComponentProps, ['optionOnly', 'isOnlyValue', 'quickcopy']);
|
|
466
475
|
|
|
467
476
|
switch (con) {
|
|
@@ -589,7 +598,8 @@ var EditableCell = function EditableCell(props) {
|
|
|
589
598
|
|
|
590
599
|
case 'render':
|
|
591
600
|
{
|
|
592
|
-
var
|
|
601
|
+
var _resultComponentProps = resultComponentProps,
|
|
602
|
+
render = _resultComponentProps.render;
|
|
593
603
|
var fromData = form.getFieldsValue();
|
|
594
604
|
return render === null || render === void 0 ? void 0 : render(Object.assign(Object.assign({}, !isObjEmpty(fromData) ? Object.assign(Object.assign({}, record), _defineProperty({}, dataIndex, fromData[dataIndex])) : record), {
|
|
595
605
|
onChange: save
|
|
@@ -698,7 +708,8 @@ var EditableCell = function EditableCell(props) {
|
|
|
698
708
|
var MemoEditableCell = /*#__PURE__*/memo(EditableCell, function (prev, next) {
|
|
699
709
|
var pickProps = ['record', 'colIndex'];
|
|
700
710
|
var p = pick(prev, pickProps);
|
|
701
|
-
var n = pick(next, pickProps);
|
|
711
|
+
var n = pick(next, pickProps);
|
|
712
|
+
console.log(prev, next, 222); // console.log(prev, next, '22', checkMemoShouldUploadSpecialFun(prev, next), isEqual(p, n))
|
|
702
713
|
|
|
703
714
|
/** TODO: 在record中带有children,子列表数据修改之后,会导致父级的record对比不一样 */
|
|
704
715
|
|
|
@@ -975,26 +986,41 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
975
986
|
|
|
976
987
|
var rkey = isObject(record) ? record[_rowKey] : record;
|
|
977
988
|
var preKeys = (_b = (_a = deepDataSourceRef === null || deepDataSourceRef === void 0 ? void 0 : deepDataSourceRef.current) === null || _a === void 0 ? void 0 : _a[rkey]) === null || _b === void 0 ? void 0 : _b.preKeys;
|
|
989
|
+
console.log(record, isAppendInChindren, defaultRecord, '333', preKeys);
|
|
978
990
|
var res = produce(dataSourceRef.current, function (draft) {
|
|
979
|
-
var _a, _b, _c, _d;
|
|
991
|
+
var _a, _b, _c, _d, _e;
|
|
980
992
|
|
|
981
|
-
if (preKeys.length > 1) {
|
|
993
|
+
if ((preKeys === null || preKeys === void 0 ? void 0 : preKeys.length) > 1) {
|
|
982
994
|
var deeps = function deeps(children) {
|
|
983
995
|
children === null || children === void 0 ? void 0 : children.forEach(function (item, index) {
|
|
984
|
-
var _a;
|
|
996
|
+
var _a, _b;
|
|
985
997
|
|
|
986
998
|
if (preKeys === null || preKeys === void 0 ? void 0 : preKeys.includes(item[_rowKey])) {
|
|
987
999
|
if (item[_rowKey] === rkey) {
|
|
988
1000
|
if (isAppendInChindren) {
|
|
989
1001
|
if (item === null || item === void 0 ? void 0 : item.children) {
|
|
990
|
-
(
|
|
1002
|
+
if (Array.isArray(defaultRecord)) {
|
|
1003
|
+
var _a2;
|
|
1004
|
+
|
|
1005
|
+
(_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : (_a2 = _a).push.apply(_a2, _toConsumableArray(defaultRecord));
|
|
1006
|
+
} else {
|
|
1007
|
+
(_b = item === null || item === void 0 ? void 0 : item.children) === null || _b === void 0 ? void 0 : _b.push(defaultRecord || _defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
1008
|
+
}
|
|
991
1009
|
} else {
|
|
992
|
-
|
|
1010
|
+
if (Array.isArray(defaultRecord)) {
|
|
1011
|
+
item.children = _toConsumableArray(defaultRecord);
|
|
1012
|
+
} else {
|
|
1013
|
+
item.children = [defaultRecord || _defineProperty({}, _rowKey, "".concat(Date.now()))];
|
|
1014
|
+
}
|
|
993
1015
|
}
|
|
994
1016
|
|
|
995
1017
|
!expandedRowKeys.includes(item[_rowKey]) && setExpandedRowKeys([].concat(_toConsumableArray(expandedRowKeys), [item[_rowKey]]));
|
|
996
1018
|
} else {
|
|
997
|
-
|
|
1019
|
+
if (Array.isArray(defaultRecord)) {
|
|
1020
|
+
children.splice.apply(children, [index + 1, 0].concat(_toConsumableArray(defaultRecord)));
|
|
1021
|
+
} else {
|
|
1022
|
+
children.splice(index + 1, 0, defaultRecord || _defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
1023
|
+
}
|
|
998
1024
|
}
|
|
999
1025
|
} else if (item.children) {
|
|
1000
1026
|
deeps(item.children);
|
|
@@ -1012,19 +1038,30 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1012
1038
|
if (index !== -1) {
|
|
1013
1039
|
if (isAppendInChindren) {
|
|
1014
1040
|
if ((_a = draft[index].children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1015
|
-
|
|
1041
|
+
if (Array.isArray(defaultRecord)) {
|
|
1042
|
+
var _b2;
|
|
1043
|
+
|
|
1044
|
+
(_b = draft[index].children) === null || _b === void 0 ? void 0 : (_b2 = _b).push.apply(_b2, _toConsumableArray(defaultRecord));
|
|
1045
|
+
} else {
|
|
1046
|
+
(_c = draft[index].children) === null || _c === void 0 ? void 0 : _c.push(defaultRecord || _defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
1047
|
+
}
|
|
1016
1048
|
} else {
|
|
1017
|
-
draft[index].children = [_defineProperty({}, _rowKey, "".concat(Date.now()))];
|
|
1049
|
+
draft[index].children = Array.isArray(defaultRecord) ? _toConsumableArray(defaultRecord) : [defaultRecord || _defineProperty({}, _rowKey, "".concat(Date.now()))];
|
|
1018
1050
|
}
|
|
1019
1051
|
|
|
1020
|
-
!expandedRowKeys.includes((
|
|
1052
|
+
!expandedRowKeys.includes((_d = draft[index]) === null || _d === void 0 ? void 0 : _d[_rowKey]) && setExpandedRowKeys([].concat(_toConsumableArray(expandedRowKeys), [(_e = draft[index]) === null || _e === void 0 ? void 0 : _e[_rowKey]]));
|
|
1021
1053
|
} else {
|
|
1022
|
-
|
|
1054
|
+
if (Array.isArray(defaultRecord)) {
|
|
1055
|
+
console.log(1);
|
|
1056
|
+
draft.splice.apply(draft, [index + 1, 0].concat(_toConsumableArray(defaultRecord)));
|
|
1057
|
+
} else {
|
|
1058
|
+
console.log(2);
|
|
1059
|
+
draft.splice(index + 1, 0, defaultRecord || _defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
1060
|
+
}
|
|
1023
1061
|
}
|
|
1024
1062
|
}
|
|
1025
1063
|
}
|
|
1026
1064
|
});
|
|
1027
|
-
console.log(preKeys, '--preKeys', res);
|
|
1028
1065
|
setDataSource(res);
|
|
1029
1066
|
};
|
|
1030
1067
|
|
|
@@ -1045,8 +1082,9 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1045
1082
|
var hasOnlyOptionsDatas = columns.filter(function (item) {
|
|
1046
1083
|
var _a;
|
|
1047
1084
|
|
|
1048
|
-
|
|
1049
|
-
|
|
1085
|
+
var resultComponentProps = isFunction(item === null || item === void 0 ? void 0 : item.componentProps) ? (_a = item === null || item === void 0 ? void 0 : item.componentProps) === null || _a === void 0 ? void 0 : _a.call(item, {}, item) : item === null || item === void 0 ? void 0 : item.componentProps;
|
|
1086
|
+
return resultComponentProps === null || resultComponentProps === void 0 ? void 0 : resultComponentProps.optionOnly;
|
|
1087
|
+
}); // const hasOnlyOptionsDatas = columns.filter((item) => item?.componentProps?.optionOnly)
|
|
1050
1088
|
|
|
1051
1089
|
if (hasOnlyOptionsDatas.length) {
|
|
1052
1090
|
return hasOnlyOptionsDatas === null || hasOnlyOptionsDatas === void 0 ? void 0 : hasOnlyOptionsDatas.map(function (item) {
|
|
@@ -1060,9 +1098,13 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1060
1098
|
|
|
1061
1099
|
var DisableOptions = useMemo(function () {
|
|
1062
1100
|
var newColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (item) {
|
|
1063
|
-
var
|
|
1064
|
-
|
|
1065
|
-
|
|
1101
|
+
var _a;
|
|
1102
|
+
|
|
1103
|
+
var resultComponentProps = isFunction(item.componentProps) ? (_a = item.componentProps) === null || _a === void 0 ? void 0 : _a.call(item, {}, item) : item.componentProps;
|
|
1104
|
+
|
|
1105
|
+
var _ref9 = resultComponentProps || {},
|
|
1106
|
+
optionOnly = _ref9.optionOnly,
|
|
1107
|
+
options = _ref9.options;
|
|
1066
1108
|
|
|
1067
1109
|
if (optionOnly && options) {
|
|
1068
1110
|
var dataIndex = item.dataIndex;
|
|
@@ -1074,6 +1116,13 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1074
1116
|
disabled: !!dataIndexData.includes(o === null || o === void 0 ? void 0 : o.value)
|
|
1075
1117
|
});
|
|
1076
1118
|
});
|
|
1119
|
+
|
|
1120
|
+
if (isFunction(item.componentProps)) {
|
|
1121
|
+
return Object.assign(Object.assign({}, item), {
|
|
1122
|
+
newOptions: newOptions
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1077
1126
|
return Object.assign(Object.assign({}, item), {
|
|
1078
1127
|
componentProps: Object.assign(Object.assign({}, item.componentProps), {
|
|
1079
1128
|
options: newOptions
|
|
@@ -1101,7 +1150,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1101
1150
|
fixed: 'left',
|
|
1102
1151
|
render: function render(_, record) {
|
|
1103
1152
|
return /*#__PURE__*/React.createElement(DragHandle, {
|
|
1104
|
-
id: record[_rowKey] || record.id
|
|
1153
|
+
id: record[_rowKey] || (record === null || record === void 0 ? void 0 : record.id)
|
|
1105
1154
|
});
|
|
1106
1155
|
}
|
|
1107
1156
|
} : null, indexCol ? isBoolean(indexCol) ? {
|
|
@@ -1251,8 +1300,8 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1251
1300
|
deleteRowData: function deleteRowData(data) {
|
|
1252
1301
|
return handleTableRowDelete(data);
|
|
1253
1302
|
},
|
|
1254
|
-
addRowData: function addRowData(data,
|
|
1255
|
-
return handleTableRowAdd(data,
|
|
1303
|
+
addRowData: function addRowData(data, defaultValue, addInChild) {
|
|
1304
|
+
return handleTableRowAdd(data, addInChild, defaultValue);
|
|
1256
1305
|
},
|
|
1257
1306
|
clearSelect: function clearSelect() {
|
|
1258
1307
|
setLocalRowSelectList({
|
|
@@ -12,24 +12,49 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
import React, { forwardRef } from 'react';
|
|
15
|
-
import { useSortable } from '@dnd-kit/sortable';
|
|
16
|
-
|
|
17
|
-
import { CSS } from '@dnd-kit/utilities';
|
|
15
|
+
import { useSortable } from '@dnd-kit/sortable'; // import { omit } from 'lodash'
|
|
16
|
+
|
|
17
|
+
import { CSS } from '@dnd-kit/utilities'; // interface ItemType {
|
|
18
|
+
// children: React.ReactNode
|
|
19
|
+
// }
|
|
20
|
+
// interface ItemInstance {}
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
|
|
18
23
|
var Item = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
19
24
|
var children = _a.children,
|
|
20
|
-
props = __rest(_a, ["children"]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
25
|
+
props = __rest(_a, ["children"]); // const rProps = omit({ ...props, ...children.props }, [
|
|
26
|
+
// 'isSticky',
|
|
27
|
+
// 'colStart',
|
|
28
|
+
// 'colEnd',
|
|
29
|
+
// 'prefixCls',
|
|
30
|
+
// 'fixLeft',
|
|
31
|
+
// 'fixRight',
|
|
32
|
+
// 'lastFixLeft',
|
|
33
|
+
// 'firstFixRight',
|
|
34
|
+
// 'lastFixRight',
|
|
35
|
+
// 'firstFixLeft',
|
|
36
|
+
// 'isSticky',
|
|
37
|
+
// 'additionalProps',
|
|
38
|
+
// 'rowType',
|
|
39
|
+
// ])
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
/*#__PURE__*/
|
|
44
|
+
// <th {...rProps} ref={ref as any} />
|
|
45
|
+
React.createElement("th", Object.assign({}, props, children.props, {
|
|
46
|
+
ref: ref
|
|
47
|
+
})) // <th {...props} ref={ref as any}>
|
|
48
|
+
// {(children as any)?.props?.children || children}
|
|
49
|
+
// </th>
|
|
50
|
+
|
|
51
|
+
);
|
|
29
52
|
});
|
|
30
53
|
export default function SortableItem(props) {
|
|
54
|
+
var id = props.id;
|
|
55
|
+
|
|
31
56
|
var _useSortable = useSortable({
|
|
32
|
-
id:
|
|
57
|
+
id: id
|
|
33
58
|
}),
|
|
34
59
|
attributes = _useSortable.attributes,
|
|
35
60
|
listeners = _useSortable.listeners,
|
package/es/LmEditTable/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import { keyBy, isEqual, pick } from 'lodash';
|
|
3
|
+
import { keyBy, isEqual, pick, isFunction } from 'lodash';
|
|
4
4
|
export function isObjEmpty(obj) {
|
|
5
5
|
var _a;
|
|
6
6
|
|
|
@@ -61,7 +61,7 @@ export function getExpandStatus(children) {
|
|
|
61
61
|
return isExpandRow(children) ? (_e = (_d = (_c = (_b = (_a = children === null || children === void 0 ? void 0 : children[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e['aria-label'] : '';
|
|
62
62
|
}
|
|
63
63
|
export function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
65
65
|
|
|
66
66
|
var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
|
|
67
67
|
|
|
@@ -86,7 +86,14 @@ export function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
if ((((_c = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _c === void 0 ? void 0 : _c.optionOnly) || ((_d = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _d === void 0 ? void 0 : _d.optionOnly)) && !isEqual((_e = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _e === void 0 ? void 0 : _e.options, (_f = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _f === void 0 ? void 0 : _f.options)) {
|
|
89
|
-
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if ((((_g = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _g === void 0 ? void 0 : _g.options) || ((_h = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _h === void 0 ? void 0 : _h.options)) && !isEqual((_j = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _j === void 0 ? void 0 : _j.options, (_k = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _k === void 0 ? void 0 : _k.options)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ((isFunction(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) || isFunction(nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps)) && !isEqual(prevCol.newOptions, nextCol.newOptions) && !isEqual(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps, nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps)) {
|
|
90
97
|
return false;
|
|
91
98
|
}
|
|
92
99
|
|
|
@@ -95,13 +102,17 @@ export function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
|
95
102
|
return false;
|
|
96
103
|
}
|
|
97
104
|
|
|
105
|
+
if (next.className.indexOf('drag-visible') > -1) {
|
|
106
|
+
return isEqual(prev.style, next.style);
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
if (next.className.indexOf('ant-table-selection-column') > -1) {
|
|
99
|
-
return isEqual((
|
|
110
|
+
return isEqual((_m = (_l = prev.children) === null || _l === void 0 ? void 0 : _l[1]) === null || _m === void 0 ? void 0 : _m.props, (_p = (_o = next.children) === null || _o === void 0 ? void 0 : _o[1]) === null || _p === void 0 ? void 0 : _p.props);
|
|
100
111
|
}
|
|
101
112
|
/** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
|
|
102
113
|
|
|
103
114
|
|
|
104
|
-
if (((
|
|
115
|
+
if (((_q = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _q === void 0 ? void 0 : _q.quickcopy) || ((_r = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _r === void 0 ? void 0 : _r.quickcopy)) {
|
|
105
116
|
var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
|
|
106
117
|
var p = pick(prev, pickProps);
|
|
107
118
|
var n = pick(next, pickProps);
|
|
@@ -33,7 +33,7 @@ export interface CountdownHandle {
|
|
|
33
33
|
clearSelect: () => void;
|
|
34
34
|
customSetCheckboxRecords: (data: any[]) => void;
|
|
35
35
|
deleteRowData: (record: string | Record<string, any>) => void;
|
|
36
|
-
addRowData: (record: string | Record<string, any>,
|
|
36
|
+
addRowData: (record: string | Record<string, any>, defaultValue?: Record<string, any> | Record<string, any>[], addInChild?: boolean) => void;
|
|
37
37
|
valid: () => void;
|
|
38
38
|
}
|
|
39
39
|
interface ILmColumns extends TableColumnType<any> {
|
|
@@ -494,7 +494,16 @@ var EditableCell = function EditableCell(props) {
|
|
|
494
494
|
};
|
|
495
495
|
|
|
496
496
|
var Control = function Control(con) {
|
|
497
|
+
var _a;
|
|
498
|
+
|
|
497
499
|
var resultComponentProps = (0, _lodash.isFunction)(componentProps) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps(record, col) : componentProps;
|
|
500
|
+
|
|
501
|
+
if ((0, _lodash.isFunction)(componentProps) && ((_a = col === null || col === void 0 ? void 0 : col.newOptions) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
502
|
+
resultComponentProps = Object.assign(Object.assign({}, resultComponentProps), {
|
|
503
|
+
options: col === null || col === void 0 ? void 0 : col.newOptions
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
498
507
|
var clearAttrComponentProps = (0, _lodash.omit)(resultComponentProps, ['optionOnly', 'isOnlyValue', 'quickcopy']);
|
|
499
508
|
|
|
500
509
|
switch (con) {
|
|
@@ -622,7 +631,8 @@ var EditableCell = function EditableCell(props) {
|
|
|
622
631
|
|
|
623
632
|
case 'render':
|
|
624
633
|
{
|
|
625
|
-
var
|
|
634
|
+
var _resultComponentProps = resultComponentProps,
|
|
635
|
+
render = _resultComponentProps.render;
|
|
626
636
|
var fromData = form.getFieldsValue();
|
|
627
637
|
return render === null || render === void 0 ? void 0 : render(Object.assign(Object.assign({}, !(0, _util.isObjEmpty)(fromData) ? Object.assign(Object.assign({}, record), (0, _defineProperty2.default)({}, dataIndex, fromData[dataIndex])) : record), {
|
|
628
638
|
onChange: save
|
|
@@ -731,7 +741,8 @@ var EditableCell = function EditableCell(props) {
|
|
|
731
741
|
var MemoEditableCell = /*#__PURE__*/(0, _react.memo)(EditableCell, function (prev, next) {
|
|
732
742
|
var pickProps = ['record', 'colIndex'];
|
|
733
743
|
var p = (0, _lodash.pick)(prev, pickProps);
|
|
734
|
-
var n = (0, _lodash.pick)(next, pickProps);
|
|
744
|
+
var n = (0, _lodash.pick)(next, pickProps);
|
|
745
|
+
console.log(prev, next, 222); // console.log(prev, next, '22', checkMemoShouldUploadSpecialFun(prev, next), isEqual(p, n))
|
|
735
746
|
|
|
736
747
|
/** TODO: 在record中带有children,子列表数据修改之后,会导致父级的record对比不一样 */
|
|
737
748
|
|
|
@@ -1008,26 +1019,41 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1008
1019
|
|
|
1009
1020
|
var rkey = (0, _lodash.isObject)(record) ? record[_rowKey] : record;
|
|
1010
1021
|
var preKeys = (_b = (_a = deepDataSourceRef === null || deepDataSourceRef === void 0 ? void 0 : deepDataSourceRef.current) === null || _a === void 0 ? void 0 : _a[rkey]) === null || _b === void 0 ? void 0 : _b.preKeys;
|
|
1022
|
+
console.log(record, isAppendInChindren, defaultRecord, '333', preKeys);
|
|
1011
1023
|
var res = (0, _immer.produce)(dataSourceRef.current, function (draft) {
|
|
1012
|
-
var _a, _b, _c, _d;
|
|
1024
|
+
var _a, _b, _c, _d, _e;
|
|
1013
1025
|
|
|
1014
|
-
if (preKeys.length > 1) {
|
|
1026
|
+
if ((preKeys === null || preKeys === void 0 ? void 0 : preKeys.length) > 1) {
|
|
1015
1027
|
var deeps = function deeps(children) {
|
|
1016
1028
|
children === null || children === void 0 ? void 0 : children.forEach(function (item, index) {
|
|
1017
|
-
var _a;
|
|
1029
|
+
var _a, _b;
|
|
1018
1030
|
|
|
1019
1031
|
if (preKeys === null || preKeys === void 0 ? void 0 : preKeys.includes(item[_rowKey])) {
|
|
1020
1032
|
if (item[_rowKey] === rkey) {
|
|
1021
1033
|
if (isAppendInChindren) {
|
|
1022
1034
|
if (item === null || item === void 0 ? void 0 : item.children) {
|
|
1023
|
-
(
|
|
1035
|
+
if (Array.isArray(defaultRecord)) {
|
|
1036
|
+
var _a2;
|
|
1037
|
+
|
|
1038
|
+
(_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : (_a2 = _a).push.apply(_a2, (0, _toConsumableArray2.default)(defaultRecord));
|
|
1039
|
+
} else {
|
|
1040
|
+
(_b = item === null || item === void 0 ? void 0 : item.children) === null || _b === void 0 ? void 0 : _b.push(defaultRecord || (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now())));
|
|
1041
|
+
}
|
|
1024
1042
|
} else {
|
|
1025
|
-
|
|
1043
|
+
if (Array.isArray(defaultRecord)) {
|
|
1044
|
+
item.children = (0, _toConsumableArray2.default)(defaultRecord);
|
|
1045
|
+
} else {
|
|
1046
|
+
item.children = [defaultRecord || (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now()))];
|
|
1047
|
+
}
|
|
1026
1048
|
}
|
|
1027
1049
|
|
|
1028
1050
|
!expandedRowKeys.includes(item[_rowKey]) && setExpandedRowKeys([].concat((0, _toConsumableArray2.default)(expandedRowKeys), [item[_rowKey]]));
|
|
1029
1051
|
} else {
|
|
1030
|
-
|
|
1052
|
+
if (Array.isArray(defaultRecord)) {
|
|
1053
|
+
children.splice.apply(children, [index + 1, 0].concat((0, _toConsumableArray2.default)(defaultRecord)));
|
|
1054
|
+
} else {
|
|
1055
|
+
children.splice(index + 1, 0, defaultRecord || (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now())));
|
|
1056
|
+
}
|
|
1031
1057
|
}
|
|
1032
1058
|
} else if (item.children) {
|
|
1033
1059
|
deeps(item.children);
|
|
@@ -1045,19 +1071,30 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1045
1071
|
if (index !== -1) {
|
|
1046
1072
|
if (isAppendInChindren) {
|
|
1047
1073
|
if ((_a = draft[index].children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1048
|
-
|
|
1074
|
+
if (Array.isArray(defaultRecord)) {
|
|
1075
|
+
var _b2;
|
|
1076
|
+
|
|
1077
|
+
(_b = draft[index].children) === null || _b === void 0 ? void 0 : (_b2 = _b).push.apply(_b2, (0, _toConsumableArray2.default)(defaultRecord));
|
|
1078
|
+
} else {
|
|
1079
|
+
(_c = draft[index].children) === null || _c === void 0 ? void 0 : _c.push(defaultRecord || (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now())));
|
|
1080
|
+
}
|
|
1049
1081
|
} else {
|
|
1050
|
-
draft[index].children = [(0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now()))];
|
|
1082
|
+
draft[index].children = Array.isArray(defaultRecord) ? (0, _toConsumableArray2.default)(defaultRecord) : [defaultRecord || (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now()))];
|
|
1051
1083
|
}
|
|
1052
1084
|
|
|
1053
|
-
!expandedRowKeys.includes((
|
|
1085
|
+
!expandedRowKeys.includes((_d = draft[index]) === null || _d === void 0 ? void 0 : _d[_rowKey]) && setExpandedRowKeys([].concat((0, _toConsumableArray2.default)(expandedRowKeys), [(_e = draft[index]) === null || _e === void 0 ? void 0 : _e[_rowKey]]));
|
|
1054
1086
|
} else {
|
|
1055
|
-
|
|
1087
|
+
if (Array.isArray(defaultRecord)) {
|
|
1088
|
+
console.log(1);
|
|
1089
|
+
draft.splice.apply(draft, [index + 1, 0].concat((0, _toConsumableArray2.default)(defaultRecord)));
|
|
1090
|
+
} else {
|
|
1091
|
+
console.log(2);
|
|
1092
|
+
draft.splice(index + 1, 0, defaultRecord || (0, _defineProperty2.default)({}, _rowKey, "".concat(Date.now())));
|
|
1093
|
+
}
|
|
1056
1094
|
}
|
|
1057
1095
|
}
|
|
1058
1096
|
}
|
|
1059
1097
|
});
|
|
1060
|
-
console.log(preKeys, '--preKeys', res);
|
|
1061
1098
|
setDataSource(res);
|
|
1062
1099
|
};
|
|
1063
1100
|
|
|
@@ -1078,8 +1115,9 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1078
1115
|
var hasOnlyOptionsDatas = columns.filter(function (item) {
|
|
1079
1116
|
var _a;
|
|
1080
1117
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1118
|
+
var resultComponentProps = (0, _lodash.isFunction)(item === null || item === void 0 ? void 0 : item.componentProps) ? (_a = item === null || item === void 0 ? void 0 : item.componentProps) === null || _a === void 0 ? void 0 : _a.call(item, {}, item) : item === null || item === void 0 ? void 0 : item.componentProps;
|
|
1119
|
+
return resultComponentProps === null || resultComponentProps === void 0 ? void 0 : resultComponentProps.optionOnly;
|
|
1120
|
+
}); // const hasOnlyOptionsDatas = columns.filter((item) => item?.componentProps?.optionOnly)
|
|
1083
1121
|
|
|
1084
1122
|
if (hasOnlyOptionsDatas.length) {
|
|
1085
1123
|
return hasOnlyOptionsDatas === null || hasOnlyOptionsDatas === void 0 ? void 0 : hasOnlyOptionsDatas.map(function (item) {
|
|
@@ -1093,9 +1131,13 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1093
1131
|
|
|
1094
1132
|
var DisableOptions = (0, _react.useMemo)(function () {
|
|
1095
1133
|
var newColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (item) {
|
|
1096
|
-
var
|
|
1097
|
-
|
|
1098
|
-
|
|
1134
|
+
var _a;
|
|
1135
|
+
|
|
1136
|
+
var resultComponentProps = (0, _lodash.isFunction)(item.componentProps) ? (_a = item.componentProps) === null || _a === void 0 ? void 0 : _a.call(item, {}, item) : item.componentProps;
|
|
1137
|
+
|
|
1138
|
+
var _ref9 = resultComponentProps || {},
|
|
1139
|
+
optionOnly = _ref9.optionOnly,
|
|
1140
|
+
options = _ref9.options;
|
|
1099
1141
|
|
|
1100
1142
|
if (optionOnly && options) {
|
|
1101
1143
|
var dataIndex = item.dataIndex;
|
|
@@ -1107,6 +1149,13 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1107
1149
|
disabled: !!dataIndexData.includes(o === null || o === void 0 ? void 0 : o.value)
|
|
1108
1150
|
});
|
|
1109
1151
|
});
|
|
1152
|
+
|
|
1153
|
+
if ((0, _lodash.isFunction)(item.componentProps)) {
|
|
1154
|
+
return Object.assign(Object.assign({}, item), {
|
|
1155
|
+
newOptions: newOptions
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1110
1159
|
return Object.assign(Object.assign({}, item), {
|
|
1111
1160
|
componentProps: Object.assign(Object.assign({}, item.componentProps), {
|
|
1112
1161
|
options: newOptions
|
|
@@ -1134,7 +1183,7 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1134
1183
|
fixed: 'left',
|
|
1135
1184
|
render: function render(_, record) {
|
|
1136
1185
|
return /*#__PURE__*/_react.default.createElement(_DragHandle.default, {
|
|
1137
|
-
id: record[_rowKey] || record.id
|
|
1186
|
+
id: record[_rowKey] || (record === null || record === void 0 ? void 0 : record.id)
|
|
1138
1187
|
});
|
|
1139
1188
|
}
|
|
1140
1189
|
} : null, indexCol ? (0, _lodash.isBoolean)(indexCol) ? {
|
|
@@ -1283,8 +1332,8 @@ var EditTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
1283
1332
|
deleteRowData: function deleteRowData(data) {
|
|
1284
1333
|
return handleTableRowDelete(data);
|
|
1285
1334
|
},
|
|
1286
|
-
addRowData: function addRowData(data,
|
|
1287
|
-
return handleTableRowAdd(data,
|
|
1335
|
+
addRowData: function addRowData(data, defaultValue, addInChild) {
|
|
1336
|
+
return handleTableRowAdd(data, addInChild, defaultValue);
|
|
1288
1337
|
},
|
|
1289
1338
|
clearSelect: function clearSelect() {
|
|
1290
1339
|
setLocalRowSelectList({
|
|
@@ -11,8 +11,6 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _sortable = require("@dnd-kit/sortable");
|
|
13
13
|
|
|
14
|
-
var _lodash = require("lodash");
|
|
15
|
-
|
|
16
14
|
var _utilities = require("@dnd-kit/utilities");
|
|
17
15
|
|
|
18
16
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
@@ -28,22 +26,47 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
|
28
26
|
return t;
|
|
29
27
|
};
|
|
30
28
|
|
|
29
|
+
// interface ItemType {
|
|
30
|
+
// children: React.ReactNode
|
|
31
|
+
// }
|
|
32
|
+
// interface ItemInstance {}
|
|
33
|
+
// @ts-ignore
|
|
31
34
|
var Item = /*#__PURE__*/(0, _react.forwardRef)(function (_a, ref) {
|
|
32
35
|
var children = _a.children,
|
|
33
|
-
props = __rest(_a, ["children"]);
|
|
36
|
+
props = __rest(_a, ["children"]); // const rProps = omit({ ...props, ...children.props }, [
|
|
37
|
+
// 'isSticky',
|
|
38
|
+
// 'colStart',
|
|
39
|
+
// 'colEnd',
|
|
40
|
+
// 'prefixCls',
|
|
41
|
+
// 'fixLeft',
|
|
42
|
+
// 'fixRight',
|
|
43
|
+
// 'lastFixLeft',
|
|
44
|
+
// 'firstFixRight',
|
|
45
|
+
// 'lastFixRight',
|
|
46
|
+
// 'firstFixLeft',
|
|
47
|
+
// 'isSticky',
|
|
48
|
+
// 'additionalProps',
|
|
49
|
+
// 'rowType',
|
|
50
|
+
// ])
|
|
51
|
+
|
|
34
52
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ref
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
return (
|
|
54
|
+
/*#__PURE__*/
|
|
55
|
+
// <th {...rProps} ref={ref as any} />
|
|
56
|
+
_react.default.createElement("th", Object.assign({}, props, children.props, {
|
|
57
|
+
ref: ref
|
|
58
|
+
})) // <th {...props} ref={ref as any}>
|
|
59
|
+
// {(children as any)?.props?.children || children}
|
|
60
|
+
// </th>
|
|
61
|
+
|
|
62
|
+
);
|
|
42
63
|
});
|
|
43
64
|
|
|
44
65
|
function SortableItem(props) {
|
|
66
|
+
var id = props.id;
|
|
67
|
+
|
|
45
68
|
var _useSortable = (0, _sortable.useSortable)({
|
|
46
|
-
id:
|
|
69
|
+
id: id
|
|
47
70
|
}),
|
|
48
71
|
attributes = _useSortable.attributes,
|
|
49
72
|
listeners = _useSortable.listeners,
|
package/lib/LmEditTable/util.js
CHANGED
|
@@ -84,7 +84,7 @@ function getExpandStatus(children) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
87
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
87
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
88
88
|
|
|
89
89
|
var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
|
|
90
90
|
|
|
@@ -109,7 +109,14 @@ function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if ((((_c = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _c === void 0 ? void 0 : _c.optionOnly) || ((_d = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _d === void 0 ? void 0 : _d.optionOnly)) && !(0, _lodash.isEqual)((_e = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _e === void 0 ? void 0 : _e.options, (_f = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _f === void 0 ? void 0 : _f.options)) {
|
|
112
|
-
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if ((((_g = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _g === void 0 ? void 0 : _g.options) || ((_h = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _h === void 0 ? void 0 : _h.options)) && !(0, _lodash.isEqual)((_j = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _j === void 0 ? void 0 : _j.options, (_k = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _k === void 0 ? void 0 : _k.options)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (((0, _lodash.isFunction)(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) || (0, _lodash.isFunction)(nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps)) && !(0, _lodash.isEqual)(prevCol.newOptions, nextCol.newOptions) && !(0, _lodash.isEqual)(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps, nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps)) {
|
|
113
120
|
return false;
|
|
114
121
|
}
|
|
115
122
|
|
|
@@ -118,13 +125,17 @@ function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
|
118
125
|
return false;
|
|
119
126
|
}
|
|
120
127
|
|
|
128
|
+
if (next.className.indexOf('drag-visible') > -1) {
|
|
129
|
+
return (0, _lodash.isEqual)(prev.style, next.style);
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
if (next.className.indexOf('ant-table-selection-column') > -1) {
|
|
122
|
-
return (0, _lodash.isEqual)((
|
|
133
|
+
return (0, _lodash.isEqual)((_m = (_l = prev.children) === null || _l === void 0 ? void 0 : _l[1]) === null || _m === void 0 ? void 0 : _m.props, (_p = (_o = next.children) === null || _o === void 0 ? void 0 : _o[1]) === null || _p === void 0 ? void 0 : _p.props);
|
|
123
134
|
}
|
|
124
135
|
/** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
|
|
125
136
|
|
|
126
137
|
|
|
127
|
-
if (((
|
|
138
|
+
if (((_q = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _q === void 0 ? void 0 : _q.quickcopy) || ((_r = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _r === void 0 ? void 0 : _r.quickcopy)) {
|
|
128
139
|
var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
|
|
129
140
|
var p = (0, _lodash.pick)(prev, pickProps);
|
|
130
141
|
var n = (0, _lodash.pick)(next, pickProps);
|