linkmore-design 1.1.11 → 1.1.13-alpha.0
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/CHANGELOG.md +34 -0
- package/dist/Cascader/demos/formItem.d.ts +2 -0
- package/dist/LmEditTable/DndContainer.d.ts +4 -3
- package/dist/LmEditTable/EditTable.d.ts +2 -0
- package/dist/LmEditTable/components/DraggableContainer.d.ts +7 -0
- package/dist/LmEditTable/components/index.d.ts +11 -0
- package/dist/LmEditTable/sortableItem.d.ts +3 -2
- package/dist/LmEditTable/util.d.ts +2 -0
- package/dist/LmEditTable/virtual/VirtualRow.d.ts +6 -0
- package/dist/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/dist/LmEditTable/virtual/VirtualTable.d.ts +3 -0
- package/dist/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
- package/dist/LmEditTable/virtual/context.d.ts +13 -0
- package/dist/LmEditTable/virtual/index.d.ts +4 -0
- package/dist/Select/demos/formItem.d.ts +2 -0
- package/dist/Select/index.d.ts +1 -0
- package/dist/TreeSelect/demos/formItem.d.ts +2 -0
- package/dist/TreeSelect/index.d.ts +8 -3
- package/dist/index.umd.js +629 -226
- package/dist/index.umd.min.js +5 -5
- package/dist/variables.css +47 -0
- package/es/IconFont/index.js +1 -1
- package/es/LmEditTable/DndContainer.d.ts +4 -3
- package/es/LmEditTable/DndContainer.js +2 -2
- package/es/LmEditTable/EditTable.d.ts +2 -0
- package/es/LmEditTable/EditTable.js +200 -158
- package/es/LmEditTable/components/DraggableContainer.d.ts +7 -0
- package/es/LmEditTable/components/DraggableContainer.js +32 -0
- package/es/LmEditTable/components/index.d.ts +11 -0
- package/es/LmEditTable/components/index.js +5 -0
- package/es/LmEditTable/sortableItem.d.ts +3 -2
- package/es/LmEditTable/sortableItem.js +15 -4
- package/es/LmEditTable/style/index.css +47 -0
- package/es/LmEditTable/style/variables.css +47 -0
- package/es/LmEditTable/util.d.ts +2 -0
- package/es/LmEditTable/util.js +37 -1
- package/es/LmEditTable/virtual/VirtualRow.d.ts +6 -0
- package/es/LmEditTable/virtual/VirtualRow.js +60 -0
- package/es/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/es/LmEditTable/virtual/VirtualRowBack.js +102 -0
- package/es/LmEditTable/virtual/VirtualTable.d.ts +3 -0
- package/es/LmEditTable/virtual/VirtualTable.js +54 -0
- package/es/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
- package/es/LmEditTable/virtual/VirtualWrapper.js +60 -0
- package/es/LmEditTable/virtual/context.d.ts +13 -0
- package/es/LmEditTable/virtual/context.js +54 -0
- package/es/LmEditTable/virtual/index.d.ts +4 -0
- package/es/LmEditTable/virtual/index.js +4 -0
- package/es/Select/index.d.ts +1 -0
- package/es/Select/index.js +38 -4
- package/es/TreeSelect/index.d.ts +8 -3
- package/es/TreeSelect/index.js +74 -1
- package/es/hooks/useEvent/index.js +1 -1
- package/es/styles/variables.css +47 -0
- package/lib/IconFont/index.js +1 -1
- package/lib/LmEditTable/DndContainer.d.ts +4 -3
- package/lib/LmEditTable/DndContainer.js +4 -3
- package/lib/LmEditTable/EditTable.d.ts +2 -0
- package/lib/LmEditTable/EditTable.js +195 -153
- package/lib/LmEditTable/components/DraggableContainer.d.ts +7 -0
- package/lib/LmEditTable/components/DraggableContainer.js +45 -0
- package/lib/LmEditTable/components/index.d.ts +11 -0
- package/lib/LmEditTable/components/index.js +21 -0
- package/lib/LmEditTable/sortableItem.d.ts +3 -2
- package/lib/LmEditTable/sortableItem.js +18 -5
- package/lib/LmEditTable/style/index.css +47 -0
- package/lib/LmEditTable/style/variables.css +47 -0
- package/lib/LmEditTable/util.d.ts +2 -0
- package/lib/LmEditTable/util.js +40 -0
- package/lib/LmEditTable/virtual/VirtualRow.d.ts +6 -0
- package/lib/LmEditTable/virtual/VirtualRow.js +73 -0
- package/lib/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/lib/LmEditTable/virtual/VirtualRowBack.js +115 -0
- package/lib/LmEditTable/virtual/VirtualTable.d.ts +3 -0
- package/lib/LmEditTable/virtual/VirtualTable.js +71 -0
- package/lib/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
- package/lib/LmEditTable/virtual/VirtualWrapper.js +73 -0
- package/lib/LmEditTable/virtual/context.d.ts +13 -0
- package/lib/LmEditTable/virtual/context.js +64 -0
- package/lib/LmEditTable/virtual/index.d.ts +4 -0
- package/lib/LmEditTable/virtual/index.js +31 -0
- package/lib/Select/index.d.ts +1 -0
- package/lib/Select/index.js +37 -3
- package/lib/TreeSelect/index.d.ts +8 -3
- package/lib/TreeSelect/index.js +78 -1
- package/lib/hooks/useEvent/index.js +1 -1
- package/lib/styles/variables.css +47 -0
- package/package.json +1 -1
|
@@ -53,26 +53,29 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
53
53
|
import { PlusCircleOutlined } from '@ant-design/icons';
|
|
54
54
|
import moment from 'moment';
|
|
55
55
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
56
|
-
import { Button, Checkbox, IconFont, Input, InputNumber, Radio, Select, Table, Switch, DatePicker, Form } from 'linkmore-design';
|
|
57
|
-
import { get, set, isFunction, omit } from 'lodash';
|
|
56
|
+
import { Button, Checkbox, IconFont, Input, InputNumber, Radio, Select, Table, Switch, DatePicker, Form, Popover } from 'linkmore-design';
|
|
57
|
+
import { get, set, isFunction, omit, isEqual, pick } from 'lodash';
|
|
58
58
|
import React, { forwardRef, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState, memo, useCallback } from 'react';
|
|
59
59
|
import { useControllableValue } from 'ahooks';
|
|
60
60
|
import { produce } from 'immer';
|
|
61
|
-
import DndContainer from './DndContainer';
|
|
62
|
-
|
|
61
|
+
import DndContainer from './DndContainer'; // import SortableBox from './sortableBox';
|
|
62
|
+
|
|
63
63
|
import SortableBoxCol from './sortableBoxCol';
|
|
64
64
|
import SortableItem from './sortableItem';
|
|
65
65
|
import ColSortableItem from './sortableItemCol';
|
|
66
66
|
import DragHandle from './DragHandle';
|
|
67
67
|
import UploadOss from '../UploadOss';
|
|
68
|
-
import { isObjEmpty, deepDataSourcePreKeys, isExpandRow, checkRowKeyByDataSource } from './util';
|
|
69
|
-
import
|
|
68
|
+
import { isObjEmpty, deepDataSourcePreKeys, isExpandRow, checkRowKeyByDataSource, checkMemoShouldUploadSpecialFun } from './util';
|
|
69
|
+
import { DraggableContainer } from './components';
|
|
70
|
+
import cls from 'classnames';
|
|
71
|
+
import { VirtualTable, VirtualWrapper, VirtualRow } from './virtual';
|
|
70
72
|
var UploadBtn = UploadOss.UploadBtn;
|
|
71
73
|
var EditableContext = /*#__PURE__*/React.createContext(null); // 表格行
|
|
72
74
|
|
|
73
75
|
var EditableRow = function EditableRow(_a) {
|
|
74
76
|
var index = _a.index,
|
|
75
|
-
|
|
77
|
+
virtual = _a.virtual,
|
|
78
|
+
props = __rest(_a, ["index", "virtual"]);
|
|
76
79
|
|
|
77
80
|
var _Form$useForm = Form.useForm(),
|
|
78
81
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -83,7 +86,7 @@ var EditableRow = function EditableRow(_a) {
|
|
|
83
86
|
component: false
|
|
84
87
|
}, /*#__PURE__*/React.createElement(EditableContext.Provider, {
|
|
85
88
|
value: form
|
|
86
|
-
}, /*#__PURE__*/React.createElement("tr", Object.assign({}, props))));
|
|
89
|
+
}, virtual ? /*#__PURE__*/React.createElement(VirtualRow, Object.assign({}, props)) : /*#__PURE__*/React.createElement("tr", Object.assign({}, props))));
|
|
87
90
|
};
|
|
88
91
|
|
|
89
92
|
var EditableSortRow = function EditableSortRow(_a) {
|
|
@@ -238,6 +241,15 @@ var Opetate = function Opetate(_ref) {
|
|
|
238
241
|
options = _ref$options === void 0 ? ['add', 'delete'] : _ref$options,
|
|
239
242
|
getLength = _ref.getLength,
|
|
240
243
|
quickOpetateClearAll = _ref.quickOpetateClearAll;
|
|
244
|
+
|
|
245
|
+
var appendChildren = function appendChildren() {
|
|
246
|
+
handleAdd === null || handleAdd === void 0 ? void 0 : handleAdd(record, true);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
var appendAdd = function appendAdd() {
|
|
250
|
+
handleAdd === null || handleAdd === void 0 ? void 0 : handleAdd(record);
|
|
251
|
+
};
|
|
252
|
+
|
|
241
253
|
return /*#__PURE__*/React.createElement("div", {
|
|
242
254
|
style: {
|
|
243
255
|
display: 'flex',
|
|
@@ -258,7 +270,27 @@ var Opetate = function Opetate(_ref) {
|
|
|
258
270
|
onClick: function onClick() {
|
|
259
271
|
return handleDelete(record[rowKey]);
|
|
260
272
|
}
|
|
261
|
-
}), options.includes('add') && /*#__PURE__*/React.createElement(
|
|
273
|
+
}), (options === null || options === void 0 ? void 0 : options.includes('add')) && (options === null || options === void 0 ? void 0 : options.includes('addInChildren')) ? /*#__PURE__*/React.createElement(Popover, {
|
|
274
|
+
placement: "bottom",
|
|
275
|
+
overlayClassName: "lm_table_append_add_popover",
|
|
276
|
+
open: open,
|
|
277
|
+
title: null,
|
|
278
|
+
content: /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
279
|
+
onClick: appendAdd
|
|
280
|
+
}, "\u6DFB\u52A0\u5E73\u7EA7"), /*#__PURE__*/React.createElement("li", {
|
|
281
|
+
onClick: appendChildren
|
|
282
|
+
}, "\u6DFB\u52A0\u5B50\u7EA7")),
|
|
283
|
+
trigger: "hover"
|
|
284
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
285
|
+
type: "link",
|
|
286
|
+
size: "small",
|
|
287
|
+
icon: /*#__PURE__*/React.createElement(IconFont, {
|
|
288
|
+
type: "lmweb-plus-circle-fill",
|
|
289
|
+
style: {
|
|
290
|
+
fontSize: 16
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
})) : /*#__PURE__*/React.createElement(Button, {
|
|
262
294
|
type: "link",
|
|
263
295
|
size: "small",
|
|
264
296
|
icon: /*#__PURE__*/React.createElement(IconFont, {
|
|
@@ -268,17 +300,10 @@ var Opetate = function Opetate(_ref) {
|
|
|
268
300
|
}
|
|
269
301
|
}),
|
|
270
302
|
onClick: function onClick() {
|
|
271
|
-
return handleAdd(record);
|
|
303
|
+
return handleAdd(record, (options === null || options === void 0 ? void 0 : options.includes('addInChildren')) ? true : false);
|
|
272
304
|
}
|
|
273
305
|
}));
|
|
274
|
-
};
|
|
275
|
-
// const toStringValue = JSON.stringify(verifyValue);
|
|
276
|
-
// if (verifyValue === undefined || verifyValue === null || verifyValue === '' || toStringValue === '[]' || toStringValue === '{}') {
|
|
277
|
-
// return false;
|
|
278
|
-
// }
|
|
279
|
-
// return true;
|
|
280
|
-
// }
|
|
281
|
-
|
|
306
|
+
};
|
|
282
307
|
/*
|
|
283
308
|
表格单元格
|
|
284
309
|
editEnum: 下拉框时的数据数组(非数组时是配置设置)
|
|
@@ -330,6 +355,12 @@ var EditableCell = function EditableCell(props) {
|
|
|
330
355
|
|
|
331
356
|
var inputRef = useRef(null);
|
|
332
357
|
var form = useContext(EditableContext);
|
|
358
|
+
|
|
359
|
+
var _useState5 = useState(false),
|
|
360
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
361
|
+
hoverStatus = _useState6[0],
|
|
362
|
+
setHoverStatus = _useState6[1];
|
|
363
|
+
|
|
333
364
|
useEffect(function () {
|
|
334
365
|
var _a;
|
|
335
366
|
|
|
@@ -340,13 +371,7 @@ var EditableCell = function EditableCell(props) {
|
|
|
340
371
|
|
|
341
372
|
var toggleEdit = function toggleEdit() {
|
|
342
373
|
setEditing(!editing); // form.setFieldsValue({ [dataIndex]: record[dataIndex] });
|
|
343
|
-
}; //
|
|
344
|
-
// const focusCapturedRef = useRef(false);
|
|
345
|
-
// const curValue = useMemo(() => {
|
|
346
|
-
// return record?.dataIndex
|
|
347
|
-
// }, [record])
|
|
348
|
-
// const curValueIsValid = isValidValue(curValue);
|
|
349
|
-
// 校验保存
|
|
374
|
+
}; // 校验保存
|
|
350
375
|
|
|
351
376
|
|
|
352
377
|
var save = function save(row) {
|
|
@@ -429,15 +454,15 @@ var EditableCell = function EditableCell(props) {
|
|
|
429
454
|
/** 快捷刷子,把当前的所有列的值,刷成当前的选中的列 */
|
|
430
455
|
|
|
431
456
|
|
|
432
|
-
var copyKey = function copyKey(e) {
|
|
457
|
+
var copyKey = function copyKey(e, type) {
|
|
433
458
|
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
434
459
|
var dataIndex = col.dataIndex;
|
|
435
|
-
handleCopy === null || handleCopy === void 0 ? void 0 : handleCopy(dataIndex, record[dataIndex]);
|
|
460
|
+
handleCopy === null || handleCopy === void 0 ? void 0 : handleCopy(dataIndex, record[dataIndex], type, props.rowIndex);
|
|
436
461
|
};
|
|
437
462
|
|
|
438
463
|
var Control = function Control(con) {
|
|
439
464
|
var resultComponentProps = isFunction(componentProps) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps(record, col) : componentProps;
|
|
440
|
-
var clearAttrComponentProps = omit(resultComponentProps, ['optionOnly', 'isOnlyValue']);
|
|
465
|
+
var clearAttrComponentProps = omit(resultComponentProps, ['optionOnly', 'isOnlyValue', 'quickcopy']);
|
|
441
466
|
|
|
442
467
|
switch (con) {
|
|
443
468
|
case 'input':
|
|
@@ -458,12 +483,6 @@ var EditableCell = function EditableCell(props) {
|
|
|
458
483
|
noStyle: true
|
|
459
484
|
}, /*#__PURE__*/React.cloneElement(resultComponentProps.addonAfter, {
|
|
460
485
|
onChange: handleFormItemChange
|
|
461
|
-
})) : null,
|
|
462
|
-
suffix: resultComponentProps.quickcopy ? /*#__PURE__*/React.createElement("span", {
|
|
463
|
-
className: 'lm_table_quickcopy'
|
|
464
|
-
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
465
|
-
onClick: copyKey,
|
|
466
|
-
type: 'lmweb-icon_m_brush'
|
|
467
486
|
})) : null
|
|
468
487
|
}));
|
|
469
488
|
|
|
@@ -546,7 +565,7 @@ var EditableCell = function EditableCell(props) {
|
|
|
546
565
|
|
|
547
566
|
case 'switch':
|
|
548
567
|
return /*#__PURE__*/React.createElement(Switch, Object.assign({
|
|
549
|
-
size:
|
|
568
|
+
size: "small"
|
|
550
569
|
}, clearAttrComponentProps, {
|
|
551
570
|
onChange: handleFormItemChange
|
|
552
571
|
}));
|
|
@@ -635,8 +654,7 @@ var EditableCell = function EditableCell(props) {
|
|
|
635
654
|
}
|
|
636
655
|
|
|
637
656
|
return childNode;
|
|
638
|
-
}, [col, isEdit, editing, getLength]); //
|
|
639
|
-
// 出现死循环找我
|
|
657
|
+
}, [col, isEdit, editing, getLength]); // 出现死循环找我
|
|
640
658
|
|
|
641
659
|
useEffect(function () {
|
|
642
660
|
var editable = col.editable,
|
|
@@ -644,22 +662,55 @@ var EditableCell = function EditableCell(props) {
|
|
|
644
662
|
|
|
645
663
|
if (isEdit && editable) {
|
|
646
664
|
form.setFieldsValue(_defineProperty({}, dataIndex, editable === 'date' ? moment(record[dataIndex]) : record[dataIndex]));
|
|
647
|
-
}
|
|
648
|
-
// (isEdit && editable && record[dataIndex]) ||
|
|
649
|
-
// (isHoverEdit && editable && record[dataIndex])
|
|
650
|
-
// ) {
|
|
651
|
-
// form.setFieldsValue({
|
|
652
|
-
// [dataIndex]: editable === 'date' ? moment(record[dataIndex]) : record[dataIndex],
|
|
653
|
-
// })
|
|
654
|
-
// }
|
|
655
|
-
|
|
665
|
+
}
|
|
656
666
|
}, [record]);
|
|
667
|
+
|
|
668
|
+
var handleTdHover = function handleTdHover() {
|
|
669
|
+
setHoverStatus(true);
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
var handleTdMouseOut = function handleTdMouseOut() {
|
|
673
|
+
setHoverStatus(false);
|
|
674
|
+
};
|
|
675
|
+
|
|
657
676
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, omit(clearProps, ['dataIndex']), {
|
|
658
677
|
className: cls(clearProps === null || clearProps === void 0 ? void 0 : clearProps.className, 'lm_custom_cell_td'),
|
|
678
|
+
onMouseEnter: componentProps.quickcopy ? handleTdHover : undefined,
|
|
679
|
+
onMouseLeave: componentProps.quickcopy ? handleTdMouseOut : undefined,
|
|
659
680
|
key: "r".concat(rowIndex, "_c").concat(colIndex)
|
|
660
|
-
}),
|
|
681
|
+
}), hoverStatus && props.rowIndex > 0 && /*#__PURE__*/React.createElement("span", {
|
|
682
|
+
className: 'quick_copy_warp quick_copy_up',
|
|
683
|
+
onClick: function onClick(e) {
|
|
684
|
+
return copyKey(e, 'up');
|
|
685
|
+
}
|
|
686
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
687
|
+
type: 'lmweb-icon_up'
|
|
688
|
+
})), getMemoChildNode, hoverStatus && props.rowIndex < props.getLength - 1 && /*#__PURE__*/React.createElement("span", {
|
|
689
|
+
className: 'quick_copy_warp quick_copy_down',
|
|
690
|
+
onClick: function onClick(e) {
|
|
691
|
+
return copyKey(e, 'down');
|
|
692
|
+
}
|
|
693
|
+
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
694
|
+
type: 'lmweb-icon_down'
|
|
695
|
+
})));
|
|
661
696
|
};
|
|
697
|
+
/** true 不刷新, false 刷新 */
|
|
698
|
+
|
|
662
699
|
|
|
700
|
+
var MemoEditableCell = /*#__PURE__*/memo(EditableCell, function (prev, next) {
|
|
701
|
+
var pickProps = ['record', 'colIndex'];
|
|
702
|
+
var p = pick(prev, pickProps);
|
|
703
|
+
var n = pick(next, pickProps); // console.log(prev, next, '22', checkMemoShouldUploadSpecialFun(prev, next), isEqual(p, n))
|
|
704
|
+
// console.log(prev, next, '-sss')
|
|
705
|
+
|
|
706
|
+
/** TODO: 在record中带有children,子列表数据修改之后,会导致父级的record对比不一样 */
|
|
707
|
+
|
|
708
|
+
if (!checkMemoShouldUploadSpecialFun(prev, next)) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
return isEqual(p, n);
|
|
713
|
+
});
|
|
663
714
|
var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
664
715
|
var defaultData = props.value,
|
|
665
716
|
columns = props.columns,
|
|
@@ -677,6 +728,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
677
728
|
_props$quickOpetateCl = props.quickOpetateClearAll,
|
|
678
729
|
quickOpetateClearAll = _props$quickOpetateCl === void 0 ? true : _props$quickOpetateCl,
|
|
679
730
|
rowSelection = props.rowSelection,
|
|
731
|
+
virtual = props.virtual,
|
|
680
732
|
sortOpen = props.sortOpen,
|
|
681
733
|
colSortOpen = props.colSortOpen,
|
|
682
734
|
filterChange = props.filterChange,
|
|
@@ -685,7 +737,8 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
685
737
|
recordCreatorProps = props.recordCreatorProps,
|
|
686
738
|
_props$shouldUpdate = props.shouldUpdate,
|
|
687
739
|
shouldUpdate = _props$shouldUpdate === void 0 ? false : _props$shouldUpdate,
|
|
688
|
-
resetProps = __rest(props
|
|
740
|
+
resetProps = __rest(props // const [dataSource, setDataSource] = useState([]);
|
|
741
|
+
, ["value", "columns", "isEdit", "isAdd", "onChange", "rowKey", "rowHoverEdit", "isUseForm", "isHoverEdit", "useQuickOpetate", "quickOpetateClearAll", "rowSelection", "virtual", "sortOpen", "colSortOpen", "filterChange", "size", "recordCreatorProps", "shouldUpdate"]); // const [dataSource, setDataSource] = useState([]);
|
|
689
742
|
|
|
690
743
|
|
|
691
744
|
var _useControllableValue = useControllableValue({
|
|
@@ -697,20 +750,15 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
697
750
|
setDataSource = _useControllableValue2[1]; // const [count, setCount] = useState(0);
|
|
698
751
|
|
|
699
752
|
|
|
700
|
-
var
|
|
701
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
702
|
-
_valid = _useState6[0],
|
|
703
|
-
setValid = _useState6[1];
|
|
704
|
-
|
|
705
|
-
var _useState7 = useState([]),
|
|
753
|
+
var _useState7 = useState({}),
|
|
706
754
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
707
|
-
|
|
708
|
-
|
|
755
|
+
_valid = _useState8[0],
|
|
756
|
+
setValid = _useState8[1];
|
|
709
757
|
|
|
710
758
|
var _useState9 = useState([]),
|
|
711
759
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
712
|
-
|
|
713
|
-
|
|
760
|
+
localRowSelectList = _useState10[0],
|
|
761
|
+
setLocalRowSelectList = _useState10[1];
|
|
714
762
|
/** 当前展开的列 */
|
|
715
763
|
|
|
716
764
|
|
|
@@ -719,21 +767,10 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
719
767
|
expandedRowKeys = _useState12[0],
|
|
720
768
|
setExpandedRowKeys = _useState12[1];
|
|
721
769
|
|
|
722
|
-
var dataSourceRef = useRef(
|
|
723
|
-
var
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
var onSortEnd = function onSortEnd(active, over) {
|
|
727
|
-
var cloneArr = _toConsumableArray(dataSourceRef.current);
|
|
728
|
-
|
|
729
|
-
var oldIndex = cloneArr.findIndex(function (v) {
|
|
730
|
-
return v[_rowKey] === active;
|
|
731
|
-
});
|
|
732
|
-
var newIndex = cloneArr.findIndex(function (v) {
|
|
733
|
-
return v[_rowKey] === over;
|
|
734
|
-
});
|
|
735
|
-
setDataSource(arrayMove(cloneArr, oldIndex, newIndex));
|
|
736
|
-
};
|
|
770
|
+
var dataSourceRef = useRef(dataSource);
|
|
771
|
+
var deepDataSourceRef = useRef(deepDataSourcePreKeys(dataSource, _rowKey));
|
|
772
|
+
dataSourceRef.current = dataSource;
|
|
773
|
+
deepDataSourceRef.current = deepDataSourcePreKeys(dataSource, _rowKey);
|
|
737
774
|
|
|
738
775
|
var onColSortEnd = function onColSortEnd(active, over) {
|
|
739
776
|
var _a;
|
|
@@ -771,29 +808,9 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
771
808
|
});
|
|
772
809
|
setDataSource(res); // onChange?.(res)
|
|
773
810
|
};
|
|
774
|
-
|
|
775
|
-
useEffect(function () {
|
|
776
|
-
var _a;
|
|
777
|
-
|
|
778
|
-
dataSourceRef.current = dataSource;
|
|
779
|
-
deepDataSourceRef.current = deepDataSourcePreKeys(dataSource, _rowKey);
|
|
780
|
-
|
|
781
|
-
if (sortOpen) {
|
|
782
|
-
var dataSourceKeys = dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
783
|
-
return item[_rowKey];
|
|
784
|
-
}).join(',');
|
|
785
|
-
var setCallBackFalgKeys = ((_a = sortDataSorceRef.current) === null || _a === void 0 ? void 0 : _a.map(function (item) {
|
|
786
|
-
return item[_rowKey];
|
|
787
|
-
}).join(',')) || '';
|
|
788
|
-
|
|
789
|
-
if (dataSourceKeys !== setCallBackFalgKeys) {
|
|
790
|
-
setCallBackFalg(dataSource);
|
|
791
|
-
sortDataSorceRef.current = dataSource;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
}, [dataSource]);
|
|
795
811
|
/** 本地缓存一个选择数据 */
|
|
796
812
|
|
|
813
|
+
|
|
797
814
|
useEffect(function () {
|
|
798
815
|
if (rowSelection) {
|
|
799
816
|
var selectedRowKeys = rowSelection.selectedRowKeys;
|
|
@@ -944,17 +961,31 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
944
961
|
/** 快捷添加 */
|
|
945
962
|
|
|
946
963
|
|
|
947
|
-
var handleTableRowAdd = function handleTableRowAdd(record) {
|
|
964
|
+
var handleTableRowAdd = function handleTableRowAdd(record, isAppendInChindren) {
|
|
948
965
|
var _a, _b;
|
|
949
966
|
|
|
950
967
|
var preKeys = (_b = (_a = deepDataSourceRef === null || deepDataSourceRef === void 0 ? void 0 : deepDataSourceRef.current) === null || _a === void 0 ? void 0 : _a[record[_rowKey]]) === null || _b === void 0 ? void 0 : _b.preKeys;
|
|
951
968
|
var res = produce(dataSourceRef.current, function (draft) {
|
|
969
|
+
var _a, _b, _c, _d;
|
|
970
|
+
|
|
952
971
|
if (preKeys.length > 1) {
|
|
953
972
|
var deeps = function deeps(children) {
|
|
954
973
|
children === null || children === void 0 ? void 0 : children.forEach(function (item, index) {
|
|
974
|
+
var _a;
|
|
975
|
+
|
|
955
976
|
if (preKeys === null || preKeys === void 0 ? void 0 : preKeys.includes(item[_rowKey])) {
|
|
956
977
|
if (item[_rowKey] === record[_rowKey]) {
|
|
957
|
-
|
|
978
|
+
if (isAppendInChindren) {
|
|
979
|
+
if (item === null || item === void 0 ? void 0 : item.children) {
|
|
980
|
+
(_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.push(_defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
981
|
+
} else {
|
|
982
|
+
item.children = [_defineProperty({}, _rowKey, "".concat(Date.now()))];
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
!expandedRowKeys.includes(item[_rowKey]) && setExpandedRowKeys([].concat(_toConsumableArray(expandedRowKeys), [item[_rowKey]]));
|
|
986
|
+
} else {
|
|
987
|
+
children.splice(index + 1, 0, _defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
988
|
+
}
|
|
958
989
|
} else if (item.children) {
|
|
959
990
|
deeps(item.children);
|
|
960
991
|
}
|
|
@@ -969,17 +1000,29 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
969
1000
|
});
|
|
970
1001
|
|
|
971
1002
|
if (index !== -1) {
|
|
972
|
-
|
|
1003
|
+
if (isAppendInChindren) {
|
|
1004
|
+
if ((_a = draft[index].children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1005
|
+
(_b = draft[index].children) === null || _b === void 0 ? void 0 : _b.push(_defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
1006
|
+
} else {
|
|
1007
|
+
draft[index].children = [_defineProperty({}, _rowKey, "".concat(Date.now()))];
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
!expandedRowKeys.includes((_c = draft[index]) === null || _c === void 0 ? void 0 : _c[_rowKey]) && setExpandedRowKeys([].concat(_toConsumableArray(expandedRowKeys), [(_d = draft[index]) === null || _d === void 0 ? void 0 : _d[_rowKey]]));
|
|
1011
|
+
} else {
|
|
1012
|
+
draft.splice(index + 1, 0, _defineProperty({}, _rowKey, "".concat(Date.now())));
|
|
1013
|
+
}
|
|
973
1014
|
}
|
|
974
1015
|
}
|
|
975
1016
|
});
|
|
976
1017
|
setDataSource(res);
|
|
977
1018
|
};
|
|
978
1019
|
|
|
979
|
-
var handleCopy = function handleCopy(key, value) {
|
|
1020
|
+
var handleCopy = function handleCopy(key, value, type, rowIndex) {
|
|
980
1021
|
var res = produce(dataSourceRef.current, function (draft) {
|
|
981
|
-
draft === null || draft === void 0 ? void 0 : draft.forEach(function (item) {
|
|
982
|
-
|
|
1022
|
+
draft === null || draft === void 0 ? void 0 : draft.forEach(function (item, index) {
|
|
1023
|
+
if (type === 'up' && index < rowIndex || type === 'down' && index > rowIndex) {
|
|
1024
|
+
item[key] = value;
|
|
1025
|
+
}
|
|
983
1026
|
});
|
|
984
1027
|
});
|
|
985
1028
|
setDataSource(res);
|
|
@@ -1006,9 +1049,9 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1006
1049
|
|
|
1007
1050
|
var DisableOptions = useMemo(function () {
|
|
1008
1051
|
var newColumns = columns === null || columns === void 0 ? void 0 : columns.map(function (item) {
|
|
1009
|
-
var
|
|
1010
|
-
optionOnly =
|
|
1011
|
-
options =
|
|
1052
|
+
var _ref5 = item.componentProps || {},
|
|
1053
|
+
optionOnly = _ref5.optionOnly,
|
|
1054
|
+
options = _ref5.options;
|
|
1012
1055
|
|
|
1013
1056
|
if (optionOnly && options) {
|
|
1014
1057
|
var dataIndex = item.dataIndex;
|
|
@@ -1092,19 +1135,6 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1092
1135
|
}
|
|
1093
1136
|
|
|
1094
1137
|
var newCol = Object.assign(Object.assign({}, col), {
|
|
1095
|
-
shouldCellUpdate: function shouldCellUpdate(record, prevRecord) {
|
|
1096
|
-
var _a;
|
|
1097
|
-
|
|
1098
|
-
var dataIndex = col.dataIndex,
|
|
1099
|
-
editable = col.editable,
|
|
1100
|
-
relevanceCols = col.relevanceCols;
|
|
1101
|
-
|
|
1102
|
-
if ((col === null || col === void 0 ? void 0 : col.fixed) || hasDisableOptions && hasDisableOptions.includes(dataIndex) || ((_a = col.componentProps) === null || _a === void 0 ? void 0 : _a.options) || editable === 'render' || !!relevanceCols || !!shouldUpdate) {
|
|
1103
|
-
return true;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
return record[dataIndex] !== prevRecord[dataIndex];
|
|
1107
|
-
},
|
|
1108
1138
|
onCell: function onCell(record, rowIndex) {
|
|
1109
1139
|
return {
|
|
1110
1140
|
getLength: dataSource.length,
|
|
@@ -1144,20 +1174,20 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1144
1174
|
return mapColumns(col, index);
|
|
1145
1175
|
});
|
|
1146
1176
|
return res;
|
|
1147
|
-
}, [columns, isAdd, sortOpen, useQuickOpetate,
|
|
1148
|
-
var DraggableContainer = useCallback(function (_a) {
|
|
1149
|
-
var _b;
|
|
1177
|
+
}, [columns, isAdd, sortOpen, useQuickOpetate, dataSource, _toConsumableArray(memoOptions)]);
|
|
1150
1178
|
|
|
1151
|
-
|
|
1179
|
+
var onSortEnd = function onSortEnd(active, over) {
|
|
1180
|
+
var cloneArr = _toConsumableArray(dataSourceRef.current);
|
|
1181
|
+
|
|
1182
|
+
var oldIndex = cloneArr.findIndex(function (v) {
|
|
1183
|
+
return v[_rowKey] === active;
|
|
1184
|
+
});
|
|
1185
|
+
var newIndex = cloneArr.findIndex(function (v) {
|
|
1186
|
+
return v[_rowKey] === over;
|
|
1187
|
+
});
|
|
1188
|
+
setDataSource(arrayMove(cloneArr, oldIndex, newIndex));
|
|
1189
|
+
};
|
|
1152
1190
|
|
|
1153
|
-
return /*#__PURE__*/React.createElement(DndContainer, {
|
|
1154
|
-
move: onSortEnd
|
|
1155
|
-
}, /*#__PURE__*/React.createElement(SortableBox, {
|
|
1156
|
-
items: (_b = dataSourceRef.current) === null || _b === void 0 ? void 0 : _b.map(function (item) {
|
|
1157
|
-
return item[_rowKey];
|
|
1158
|
-
})
|
|
1159
|
-
}, /*#__PURE__*/React.createElement("tbody", Object.assign({}, props))));
|
|
1160
|
-
}, [sortEditTable]);
|
|
1161
1191
|
var colDraggableContainer = useCallback(function (_a) {
|
|
1162
1192
|
var _b;
|
|
1163
1193
|
|
|
@@ -1175,34 +1205,6 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1175
1205
|
}, child);
|
|
1176
1206
|
}));
|
|
1177
1207
|
}, [columns]);
|
|
1178
|
-
var config = useMemo(function () {
|
|
1179
|
-
var component = {
|
|
1180
|
-
body: Object.assign({
|
|
1181
|
-
row: sortOpen ? EditableSortRow : EditableRow,
|
|
1182
|
-
cell: EditableCell
|
|
1183
|
-
}, sortOpen ? {
|
|
1184
|
-
wrapper: DraggableContainer
|
|
1185
|
-
} : {})
|
|
1186
|
-
};
|
|
1187
|
-
|
|
1188
|
-
if (colSortOpen) {
|
|
1189
|
-
component['header'] = {
|
|
1190
|
-
row: colDraggableContainer
|
|
1191
|
-
};
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
return Object.assign({
|
|
1195
|
-
pagination: false,
|
|
1196
|
-
tableLayout: 'fixed',
|
|
1197
|
-
scroll: {
|
|
1198
|
-
x: '100%'
|
|
1199
|
-
},
|
|
1200
|
-
rowKey: function rowKey(record) {
|
|
1201
|
-
return record[_rowKey] || record.index || Math.random();
|
|
1202
|
-
},
|
|
1203
|
-
components: component
|
|
1204
|
-
}, resetProps);
|
|
1205
|
-
}, [resultColumns, dataSource, sortOpen, colSortOpen, size]);
|
|
1206
1208
|
useImperativeHandle(ref, function () {
|
|
1207
1209
|
return {
|
|
1208
1210
|
setRow: handleSave,
|
|
@@ -1214,6 +1216,46 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1214
1216
|
var isShowAddAction = useMemo(function () {
|
|
1215
1217
|
return isEdit && isAdd || isHoverEdit && isAdd;
|
|
1216
1218
|
}, [isEdit, isAdd, isHoverEdit]);
|
|
1219
|
+
var config = useRef(Object.assign({
|
|
1220
|
+
pagination: false,
|
|
1221
|
+
tableLayout: 'fixed',
|
|
1222
|
+
scroll: {
|
|
1223
|
+
x: '100%'
|
|
1224
|
+
},
|
|
1225
|
+
rowKey: function rowKey(record) {
|
|
1226
|
+
return record[_rowKey] || record.index || Math.random();
|
|
1227
|
+
},
|
|
1228
|
+
components: {
|
|
1229
|
+
table: virtual ? VirtualTable : null,
|
|
1230
|
+
body: Object.assign({
|
|
1231
|
+
row: function row(rowProps) {
|
|
1232
|
+
return sortOpen ? EditableSortRow(Object.assign(Object.assign({}, rowProps), {
|
|
1233
|
+
virtual: virtual
|
|
1234
|
+
})) : EditableRow(Object.assign(Object.assign({}, rowProps), {
|
|
1235
|
+
virtual: virtual
|
|
1236
|
+
}));
|
|
1237
|
+
},
|
|
1238
|
+
cell: MemoEditableCell
|
|
1239
|
+
}, sortOpen ? {
|
|
1240
|
+
wrapper: function wrapper(wrapperProps) {
|
|
1241
|
+
var _a;
|
|
1242
|
+
|
|
1243
|
+
return DraggableContainer(Object.assign(Object.assign({}, wrapperProps), {
|
|
1244
|
+
virtual: virtual,
|
|
1245
|
+
keys: (_a = dataSourceRef.current) === null || _a === void 0 ? void 0 : _a.map(function (item) {
|
|
1246
|
+
return item[_rowKey];
|
|
1247
|
+
}),
|
|
1248
|
+
onSortEnd: onSortEnd
|
|
1249
|
+
}));
|
|
1250
|
+
}
|
|
1251
|
+
} : virtual ? {
|
|
1252
|
+
wrapper: VirtualWrapper
|
|
1253
|
+
} : {}),
|
|
1254
|
+
header: {
|
|
1255
|
+
row: colSortOpen ? colDraggableContainer : null
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}, resetProps));
|
|
1217
1259
|
|
|
1218
1260
|
if (colSortOpen) {
|
|
1219
1261
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1224,7 +1266,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1224
1266
|
items: columns.reduce(function (acc, item) {
|
|
1225
1267
|
return [].concat(_toConsumableArray(acc), [item.dataIndex]);
|
|
1226
1268
|
}, [])
|
|
1227
|
-
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config, {
|
|
1269
|
+
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config.current, {
|
|
1228
1270
|
size: size || 'small',
|
|
1229
1271
|
columns: resultColumns,
|
|
1230
1272
|
rowClassName: "editable-row",
|
|
@@ -1258,7 +1300,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1258
1300
|
|
|
1259
1301
|
return /*#__PURE__*/React.createElement("div", {
|
|
1260
1302
|
className: "lm_editTable_warpper"
|
|
1261
|
-
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config, {
|
|
1303
|
+
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config.current, {
|
|
1262
1304
|
size: size || 'small',
|
|
1263
1305
|
columns: resultColumns,
|
|
1264
1306
|
rowClassName: "editable-row",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import DndContainer from '../DndContainer';
|
|
16
|
+
import SortableBox from '../sortableBox';
|
|
17
|
+
import { VirtualWrapper } from '../virtual';
|
|
18
|
+
|
|
19
|
+
var DraggableContainer = function DraggableContainer(_a) {
|
|
20
|
+
var keys = _a.keys,
|
|
21
|
+
onSortEnd = _a.onSortEnd,
|
|
22
|
+
virtual = _a.virtual,
|
|
23
|
+
props = __rest(_a, ["keys", "onSortEnd", "virtual"]);
|
|
24
|
+
|
|
25
|
+
return /*#__PURE__*/React.createElement(DndContainer, {
|
|
26
|
+
move: onSortEnd
|
|
27
|
+
}, /*#__PURE__*/React.createElement(SortableBox, {
|
|
28
|
+
items: keys
|
|
29
|
+
}, virtual ? /*#__PURE__*/React.createElement(VirtualWrapper, Object.assign({}, props)) : /*#__PURE__*/React.createElement("tbody", Object.assign({}, props))));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default DraggableContainer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DraggableContainer from './DraggableContainer';
|
|
2
|
+
export { DraggableContainer };
|
|
3
|
+
declare const _default: {
|
|
4
|
+
DraggableContainer: ({ keys, onSortEnd, virtual, ...props }: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
keys: any;
|
|
7
|
+
onSortEnd: any;
|
|
8
|
+
virtual: any;
|
|
9
|
+
}) => JSX.Element;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.MemoExoticComponent<(props: any) => JSX.Element>;
|
|
3
|
+
export default _default;
|