linkmore-design 1.1.12 → 1.1.13-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -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/index.umd.js +479 -217
- package/dist/index.umd.min.js +5 -5
- package/dist/variables.css +29 -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 +139 -150
- 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 +29 -0
- package/es/LmEditTable/style/variables.css +29 -0
- package/es/LmEditTable/util.d.ts +2 -0
- package/es/LmEditTable/util.js +47 -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/hooks/useEvent/index.js +1 -1
- package/es/styles/variables.css +29 -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 +135 -146
- 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 +29 -0
- package/lib/LmEditTable/style/variables.css +29 -0
- package/lib/LmEditTable/util.d.ts +2 -0
- package/lib/LmEditTable/util.js +50 -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/hooks/useEvent/index.js +1 -1
- package/lib/styles/variables.css +29 -0
- package/package.json +1 -1
package/dist/variables.css
CHANGED
|
@@ -9742,6 +9742,9 @@ p {
|
|
|
9742
9742
|
letter-spacing: 0px;
|
|
9743
9743
|
color: var(--color-85);
|
|
9744
9744
|
}
|
|
9745
|
+
.lm_editTable_warpper .lm_custom_cell_td {
|
|
9746
|
+
position: relative;
|
|
9747
|
+
}
|
|
9745
9748
|
.lm_editTable_warpper .lm_custom_cell_td .ant-form-item-control-input-content {
|
|
9746
9749
|
display: flex;
|
|
9747
9750
|
flex-direction: row;
|
|
@@ -9753,6 +9756,32 @@ p {
|
|
|
9753
9756
|
.lm_editTable_warpper .lm_custom_cell_td .ant-table-row-expand-icon {
|
|
9754
9757
|
margin-top: 6px;
|
|
9755
9758
|
}
|
|
9759
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp {
|
|
9760
|
+
font-size: 8px;
|
|
9761
|
+
position: absolute;
|
|
9762
|
+
left: calc(50% - 10px);
|
|
9763
|
+
z-index: 100;
|
|
9764
|
+
width: 20px;
|
|
9765
|
+
height: 10px;
|
|
9766
|
+
background-color: var(--color-6);
|
|
9767
|
+
display: flex;
|
|
9768
|
+
align-items: center;
|
|
9769
|
+
justify-content: center;
|
|
9770
|
+
color: #D8D8D8;
|
|
9771
|
+
}
|
|
9772
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp:hover {
|
|
9773
|
+
cursor: pointer;
|
|
9774
|
+
background-color: var(--primary-color);
|
|
9775
|
+
color: #fff;
|
|
9776
|
+
}
|
|
9777
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_up {
|
|
9778
|
+
top: -4px;
|
|
9779
|
+
left: calc(50% - 10px);
|
|
9780
|
+
}
|
|
9781
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_down {
|
|
9782
|
+
bottom: -6px;
|
|
9783
|
+
left: calc(50% - 10px);
|
|
9784
|
+
}
|
|
9756
9785
|
.lm_editTable_warpper .lm_editTable_cell_edit {
|
|
9757
9786
|
height: 40px;
|
|
9758
9787
|
padding: 8px 8px !important;
|
package/es/IconFont/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createFromIconfontCN } from '@ant-design/icons';
|
|
2
2
|
var IconFont = createFromIconfontCN({
|
|
3
|
-
scriptUrl: '//at.alicdn.com/t/c/
|
|
3
|
+
scriptUrl: '//at.alicdn.com/t/c/font_2966019_neaxovtw4w.js' // 在 iconfont.cn 上生成
|
|
4
4
|
// scriptUrl: require('./font/iconfont.js'),
|
|
5
5
|
|
|
6
6
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const _default: React.MemoExoticComponent<({ children, move }: {
|
|
2
3
|
children: any;
|
|
3
4
|
move: any;
|
|
4
|
-
}) => JSX.Element
|
|
5
|
-
export default
|
|
5
|
+
}) => JSX.Element>;
|
|
6
|
+
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
2
|
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
3
3
|
import { restrictToParentElement } from '@dnd-kit/modifiers';
|
|
4
4
|
import { sortableKeyboardCoordinates } from '@dnd-kit/sortable'; // 可拖拽容器
|
|
@@ -32,4 +32,4 @@ var DndContainer = function DndContainer(_ref) {
|
|
|
32
32
|
}, children);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export default DndContainer;
|
|
35
|
+
export default /*#__PURE__*/memo(DndContainer);
|
|
@@ -36,9 +36,11 @@ interface ILmColumns extends TableColumnType<any> {
|
|
|
36
36
|
export declare type TLmEditTable = {
|
|
37
37
|
onChange?: (data: any[]) => void;
|
|
38
38
|
columns: ILmColumns[];
|
|
39
|
+
virtual: boolean;
|
|
39
40
|
} & ILmEditTable;
|
|
40
41
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
|
|
41
42
|
onChange?: (data: any[]) => void;
|
|
42
43
|
columns: ILmColumns[];
|
|
44
|
+
virtual: boolean;
|
|
43
45
|
} & ILmEditTable & React.RefAttributes<unknown>>>;
|
|
44
46
|
export default _default;
|
|
@@ -54,25 +54,28 @@ import { PlusCircleOutlined } from '@ant-design/icons';
|
|
|
54
54
|
import moment from 'moment';
|
|
55
55
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
56
56
|
import { Button, Checkbox, IconFont, Input, InputNumber, Radio, Select, Table, Switch, DatePicker, Form, Popover } from 'linkmore-design';
|
|
57
|
-
import { get, set, isFunction, omit } from 'lodash';
|
|
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) {
|
|
@@ -269,7 +272,7 @@ var Opetate = function Opetate(_ref) {
|
|
|
269
272
|
}
|
|
270
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, {
|
|
271
274
|
placement: "bottom",
|
|
272
|
-
overlayClassName:
|
|
275
|
+
overlayClassName: "lm_table_append_add_popover",
|
|
273
276
|
open: open,
|
|
274
277
|
title: null,
|
|
275
278
|
content: /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", {
|
|
@@ -300,14 +303,7 @@ var Opetate = function Opetate(_ref) {
|
|
|
300
303
|
return handleAdd(record, (options === null || options === void 0 ? void 0 : options.includes('addInChildren')) ? true : false);
|
|
301
304
|
}
|
|
302
305
|
}));
|
|
303
|
-
};
|
|
304
|
-
// const toStringValue = JSON.stringify(verifyValue);
|
|
305
|
-
// if (verifyValue === undefined || verifyValue === null || verifyValue === '' || toStringValue === '[]' || toStringValue === '{}') {
|
|
306
|
-
// return false;
|
|
307
|
-
// }
|
|
308
|
-
// return true;
|
|
309
|
-
// }
|
|
310
|
-
|
|
306
|
+
};
|
|
311
307
|
/*
|
|
312
308
|
表格单元格
|
|
313
309
|
editEnum: 下拉框时的数据数组(非数组时是配置设置)
|
|
@@ -359,6 +355,12 @@ var EditableCell = function EditableCell(props) {
|
|
|
359
355
|
|
|
360
356
|
var inputRef = useRef(null);
|
|
361
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
|
+
|
|
362
364
|
useEffect(function () {
|
|
363
365
|
var _a;
|
|
364
366
|
|
|
@@ -369,13 +371,7 @@ var EditableCell = function EditableCell(props) {
|
|
|
369
371
|
|
|
370
372
|
var toggleEdit = function toggleEdit() {
|
|
371
373
|
setEditing(!editing); // form.setFieldsValue({ [dataIndex]: record[dataIndex] });
|
|
372
|
-
}; //
|
|
373
|
-
// const focusCapturedRef = useRef(false);
|
|
374
|
-
// const curValue = useMemo(() => {
|
|
375
|
-
// return record?.dataIndex
|
|
376
|
-
// }, [record])
|
|
377
|
-
// const curValueIsValid = isValidValue(curValue);
|
|
378
|
-
// 校验保存
|
|
374
|
+
}; // 校验保存
|
|
379
375
|
|
|
380
376
|
|
|
381
377
|
var save = function save(row) {
|
|
@@ -458,15 +454,15 @@ var EditableCell = function EditableCell(props) {
|
|
|
458
454
|
/** 快捷刷子,把当前的所有列的值,刷成当前的选中的列 */
|
|
459
455
|
|
|
460
456
|
|
|
461
|
-
var copyKey = function copyKey(e) {
|
|
457
|
+
var copyKey = function copyKey(e, type) {
|
|
462
458
|
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
463
459
|
var dataIndex = col.dataIndex;
|
|
464
|
-
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);
|
|
465
461
|
};
|
|
466
462
|
|
|
467
463
|
var Control = function Control(con) {
|
|
468
464
|
var resultComponentProps = isFunction(componentProps) ? componentProps === null || componentProps === void 0 ? void 0 : componentProps(record, col) : componentProps;
|
|
469
|
-
var clearAttrComponentProps = omit(resultComponentProps, ['optionOnly', 'isOnlyValue']);
|
|
465
|
+
var clearAttrComponentProps = omit(resultComponentProps, ['optionOnly', 'isOnlyValue', 'quickcopy']);
|
|
470
466
|
|
|
471
467
|
switch (con) {
|
|
472
468
|
case 'input':
|
|
@@ -487,12 +483,6 @@ var EditableCell = function EditableCell(props) {
|
|
|
487
483
|
noStyle: true
|
|
488
484
|
}, /*#__PURE__*/React.cloneElement(resultComponentProps.addonAfter, {
|
|
489
485
|
onChange: handleFormItemChange
|
|
490
|
-
})) : null,
|
|
491
|
-
suffix: resultComponentProps.quickcopy ? /*#__PURE__*/React.createElement("span", {
|
|
492
|
-
className: 'lm_table_quickcopy'
|
|
493
|
-
}, /*#__PURE__*/React.createElement(IconFont, {
|
|
494
|
-
onClick: copyKey,
|
|
495
|
-
type: 'lmweb-icon_m_brush'
|
|
496
486
|
})) : null
|
|
497
487
|
}));
|
|
498
488
|
|
|
@@ -575,7 +565,7 @@ var EditableCell = function EditableCell(props) {
|
|
|
575
565
|
|
|
576
566
|
case 'switch':
|
|
577
567
|
return /*#__PURE__*/React.createElement(Switch, Object.assign({
|
|
578
|
-
size:
|
|
568
|
+
size: "small"
|
|
579
569
|
}, clearAttrComponentProps, {
|
|
580
570
|
onChange: handleFormItemChange
|
|
581
571
|
}));
|
|
@@ -664,8 +654,7 @@ var EditableCell = function EditableCell(props) {
|
|
|
664
654
|
}
|
|
665
655
|
|
|
666
656
|
return childNode;
|
|
667
|
-
}, [col, isEdit, editing, getLength]); //
|
|
668
|
-
// 出现死循环找我
|
|
657
|
+
}, [col, isEdit, editing, getLength]); // 出现死循环找我
|
|
669
658
|
|
|
670
659
|
useEffect(function () {
|
|
671
660
|
var editable = col.editable,
|
|
@@ -673,22 +662,54 @@ var EditableCell = function EditableCell(props) {
|
|
|
673
662
|
|
|
674
663
|
if (isEdit && editable) {
|
|
675
664
|
form.setFieldsValue(_defineProperty({}, dataIndex, editable === 'date' ? moment(record[dataIndex]) : record[dataIndex]));
|
|
676
|
-
}
|
|
677
|
-
// (isEdit && editable && record[dataIndex]) ||
|
|
678
|
-
// (isHoverEdit && editable && record[dataIndex])
|
|
679
|
-
// ) {
|
|
680
|
-
// form.setFieldsValue({
|
|
681
|
-
// [dataIndex]: editable === 'date' ? moment(record[dataIndex]) : record[dataIndex],
|
|
682
|
-
// })
|
|
683
|
-
// }
|
|
684
|
-
|
|
665
|
+
}
|
|
685
666
|
}, [record]);
|
|
667
|
+
|
|
668
|
+
var handleTdHover = function handleTdHover() {
|
|
669
|
+
setHoverStatus(true);
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
var handleTdMouseOut = function handleTdMouseOut() {
|
|
673
|
+
setHoverStatus(false);
|
|
674
|
+
};
|
|
675
|
+
|
|
686
676
|
return /*#__PURE__*/React.createElement("td", Object.assign({}, omit(clearProps, ['dataIndex']), {
|
|
687
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,
|
|
688
680
|
key: "r".concat(rowIndex, "_c").concat(colIndex)
|
|
689
|
-
}),
|
|
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
|
+
})));
|
|
690
696
|
};
|
|
697
|
+
/** true 不刷新, false 刷新 */
|
|
698
|
+
|
|
691
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
|
+
|
|
705
|
+
/** TODO: 在record中带有children,子列表数据修改之后,会导致父级的record对比不一样 */
|
|
706
|
+
|
|
707
|
+
if (!checkMemoShouldUploadSpecialFun(prev, next)) {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
return isEqual(p, n);
|
|
712
|
+
});
|
|
692
713
|
var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
693
714
|
var defaultData = props.value,
|
|
694
715
|
columns = props.columns,
|
|
@@ -706,6 +727,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
706
727
|
_props$quickOpetateCl = props.quickOpetateClearAll,
|
|
707
728
|
quickOpetateClearAll = _props$quickOpetateCl === void 0 ? true : _props$quickOpetateCl,
|
|
708
729
|
rowSelection = props.rowSelection,
|
|
730
|
+
virtual = props.virtual,
|
|
709
731
|
sortOpen = props.sortOpen,
|
|
710
732
|
colSortOpen = props.colSortOpen,
|
|
711
733
|
filterChange = props.filterChange,
|
|
@@ -714,7 +736,8 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
714
736
|
recordCreatorProps = props.recordCreatorProps,
|
|
715
737
|
_props$shouldUpdate = props.shouldUpdate,
|
|
716
738
|
shouldUpdate = _props$shouldUpdate === void 0 ? false : _props$shouldUpdate,
|
|
717
|
-
resetProps = __rest(props
|
|
739
|
+
resetProps = __rest(props // const [dataSource, setDataSource] = useState([]);
|
|
740
|
+
, ["value", "columns", "isEdit", "isAdd", "onChange", "rowKey", "rowHoverEdit", "isUseForm", "isHoverEdit", "useQuickOpetate", "quickOpetateClearAll", "rowSelection", "virtual", "sortOpen", "colSortOpen", "filterChange", "size", "recordCreatorProps", "shouldUpdate"]); // const [dataSource, setDataSource] = useState([]);
|
|
718
741
|
|
|
719
742
|
|
|
720
743
|
var _useControllableValue = useControllableValue({
|
|
@@ -726,20 +749,15 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
726
749
|
setDataSource = _useControllableValue2[1]; // const [count, setCount] = useState(0);
|
|
727
750
|
|
|
728
751
|
|
|
729
|
-
var
|
|
730
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
731
|
-
_valid = _useState6[0],
|
|
732
|
-
setValid = _useState6[1];
|
|
733
|
-
|
|
734
|
-
var _useState7 = useState([]),
|
|
752
|
+
var _useState7 = useState({}),
|
|
735
753
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
736
|
-
|
|
737
|
-
|
|
754
|
+
_valid = _useState8[0],
|
|
755
|
+
setValid = _useState8[1];
|
|
738
756
|
|
|
739
757
|
var _useState9 = useState([]),
|
|
740
758
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
741
|
-
|
|
742
|
-
|
|
759
|
+
localRowSelectList = _useState10[0],
|
|
760
|
+
setLocalRowSelectList = _useState10[1];
|
|
743
761
|
/** 当前展开的列 */
|
|
744
762
|
|
|
745
763
|
|
|
@@ -748,21 +766,10 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
748
766
|
expandedRowKeys = _useState12[0],
|
|
749
767
|
setExpandedRowKeys = _useState12[1];
|
|
750
768
|
|
|
751
|
-
var dataSourceRef = useRef(
|
|
752
|
-
var
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
var onSortEnd = function onSortEnd(active, over) {
|
|
756
|
-
var cloneArr = _toConsumableArray(dataSourceRef.current);
|
|
757
|
-
|
|
758
|
-
var oldIndex = cloneArr.findIndex(function (v) {
|
|
759
|
-
return v[_rowKey] === active;
|
|
760
|
-
});
|
|
761
|
-
var newIndex = cloneArr.findIndex(function (v) {
|
|
762
|
-
return v[_rowKey] === over;
|
|
763
|
-
});
|
|
764
|
-
setDataSource(arrayMove(cloneArr, oldIndex, newIndex));
|
|
765
|
-
};
|
|
769
|
+
var dataSourceRef = useRef(dataSource);
|
|
770
|
+
var deepDataSourceRef = useRef(deepDataSourcePreKeys(dataSource, _rowKey));
|
|
771
|
+
dataSourceRef.current = dataSource;
|
|
772
|
+
deepDataSourceRef.current = deepDataSourcePreKeys(dataSource, _rowKey);
|
|
766
773
|
|
|
767
774
|
var onColSortEnd = function onColSortEnd(active, over) {
|
|
768
775
|
var _a;
|
|
@@ -800,29 +807,9 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
800
807
|
});
|
|
801
808
|
setDataSource(res); // onChange?.(res)
|
|
802
809
|
};
|
|
803
|
-
|
|
804
|
-
useEffect(function () {
|
|
805
|
-
var _a;
|
|
806
|
-
|
|
807
|
-
dataSourceRef.current = dataSource;
|
|
808
|
-
deepDataSourceRef.current = deepDataSourcePreKeys(dataSource, _rowKey);
|
|
809
|
-
|
|
810
|
-
if (sortOpen) {
|
|
811
|
-
var dataSourceKeys = dataSource === null || dataSource === void 0 ? void 0 : dataSource.map(function (item) {
|
|
812
|
-
return item[_rowKey];
|
|
813
|
-
}).join(',');
|
|
814
|
-
var setCallBackFalgKeys = ((_a = sortDataSorceRef.current) === null || _a === void 0 ? void 0 : _a.map(function (item) {
|
|
815
|
-
return item[_rowKey];
|
|
816
|
-
}).join(',')) || '';
|
|
817
|
-
|
|
818
|
-
if (dataSourceKeys !== setCallBackFalgKeys) {
|
|
819
|
-
setCallBackFalg(dataSource);
|
|
820
|
-
sortDataSorceRef.current = dataSource;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}, [dataSource]);
|
|
824
810
|
/** 本地缓存一个选择数据 */
|
|
825
811
|
|
|
812
|
+
|
|
826
813
|
useEffect(function () {
|
|
827
814
|
if (rowSelection) {
|
|
828
815
|
var selectedRowKeys = rowSelection.selectedRowKeys;
|
|
@@ -1029,10 +1016,12 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1029
1016
|
setDataSource(res);
|
|
1030
1017
|
};
|
|
1031
1018
|
|
|
1032
|
-
var handleCopy = function handleCopy(key, value) {
|
|
1019
|
+
var handleCopy = function handleCopy(key, value, type, rowIndex) {
|
|
1033
1020
|
var res = produce(dataSourceRef.current, function (draft) {
|
|
1034
|
-
draft === null || draft === void 0 ? void 0 : draft.forEach(function (item) {
|
|
1035
|
-
|
|
1021
|
+
draft === null || draft === void 0 ? void 0 : draft.forEach(function (item, index) {
|
|
1022
|
+
if (type === 'up' && index < rowIndex || type === 'down' && index > rowIndex) {
|
|
1023
|
+
item[key] = value;
|
|
1024
|
+
}
|
|
1036
1025
|
});
|
|
1037
1026
|
});
|
|
1038
1027
|
setDataSource(res);
|
|
@@ -1097,6 +1086,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1097
1086
|
width: 48,
|
|
1098
1087
|
maxWidth: 48,
|
|
1099
1088
|
className: 'drag-visible',
|
|
1089
|
+
fixed: 'left',
|
|
1100
1090
|
render: function render(_, record) {
|
|
1101
1091
|
return /*#__PURE__*/React.createElement(DragHandle, {
|
|
1102
1092
|
id: record[_rowKey] || record.id
|
|
@@ -1145,19 +1135,6 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1145
1135
|
}
|
|
1146
1136
|
|
|
1147
1137
|
var newCol = Object.assign(Object.assign({}, col), {
|
|
1148
|
-
shouldCellUpdate: function shouldCellUpdate(record, prevRecord) {
|
|
1149
|
-
var _a;
|
|
1150
|
-
|
|
1151
|
-
var dataIndex = col.dataIndex,
|
|
1152
|
-
editable = col.editable,
|
|
1153
|
-
relevanceCols = col.relevanceCols;
|
|
1154
|
-
|
|
1155
|
-
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 || !!record.children) {
|
|
1156
|
-
return true;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
return record[dataIndex] !== prevRecord[dataIndex];
|
|
1160
|
-
},
|
|
1161
1138
|
onCell: function onCell(record, rowIndex) {
|
|
1162
1139
|
return {
|
|
1163
1140
|
getLength: dataSource.length,
|
|
@@ -1197,20 +1174,20 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1197
1174
|
return mapColumns(col, index);
|
|
1198
1175
|
});
|
|
1199
1176
|
return res;
|
|
1200
|
-
}, [columns, isAdd, sortOpen, useQuickOpetate,
|
|
1201
|
-
var DraggableContainer = useCallback(function (_a) {
|
|
1202
|
-
var _b;
|
|
1177
|
+
}, [columns, isAdd, sortOpen, useQuickOpetate, dataSource, _toConsumableArray(memoOptions)]);
|
|
1203
1178
|
|
|
1204
|
-
|
|
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
|
+
};
|
|
1205
1190
|
|
|
1206
|
-
return /*#__PURE__*/React.createElement(DndContainer, {
|
|
1207
|
-
move: onSortEnd
|
|
1208
|
-
}, /*#__PURE__*/React.createElement(SortableBox, {
|
|
1209
|
-
items: (_b = dataSourceRef.current) === null || _b === void 0 ? void 0 : _b.map(function (item) {
|
|
1210
|
-
return item[_rowKey];
|
|
1211
|
-
})
|
|
1212
|
-
}, /*#__PURE__*/React.createElement("tbody", Object.assign({}, props))));
|
|
1213
|
-
}, [sortEditTable]);
|
|
1214
1191
|
var colDraggableContainer = useCallback(function (_a) {
|
|
1215
1192
|
var _b;
|
|
1216
1193
|
|
|
@@ -1228,34 +1205,6 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1228
1205
|
}, child);
|
|
1229
1206
|
}));
|
|
1230
1207
|
}, [columns]);
|
|
1231
|
-
var config = useMemo(function () {
|
|
1232
|
-
var component = {
|
|
1233
|
-
body: Object.assign({
|
|
1234
|
-
row: sortOpen ? EditableSortRow : EditableRow,
|
|
1235
|
-
cell: EditableCell
|
|
1236
|
-
}, sortOpen ? {
|
|
1237
|
-
wrapper: DraggableContainer
|
|
1238
|
-
} : {})
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
if (colSortOpen) {
|
|
1242
|
-
component['header'] = {
|
|
1243
|
-
row: colDraggableContainer
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
return Object.assign({
|
|
1248
|
-
pagination: false,
|
|
1249
|
-
tableLayout: 'fixed',
|
|
1250
|
-
scroll: {
|
|
1251
|
-
x: '100%'
|
|
1252
|
-
},
|
|
1253
|
-
rowKey: function rowKey(record) {
|
|
1254
|
-
return record[_rowKey] || record.index || Math.random();
|
|
1255
|
-
},
|
|
1256
|
-
components: component
|
|
1257
|
-
}, resetProps);
|
|
1258
|
-
}, [resultColumns, dataSource, sortOpen, colSortOpen, size]);
|
|
1259
1208
|
useImperativeHandle(ref, function () {
|
|
1260
1209
|
return {
|
|
1261
1210
|
setRow: handleSave,
|
|
@@ -1267,6 +1216,46 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1267
1216
|
var isShowAddAction = useMemo(function () {
|
|
1268
1217
|
return isEdit && isAdd || isHoverEdit && isAdd;
|
|
1269
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));
|
|
1270
1259
|
|
|
1271
1260
|
if (colSortOpen) {
|
|
1272
1261
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1277,7 +1266,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1277
1266
|
items: columns.reduce(function (acc, item) {
|
|
1278
1267
|
return [].concat(_toConsumableArray(acc), [item.dataIndex]);
|
|
1279
1268
|
}, [])
|
|
1280
|
-
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config, {
|
|
1269
|
+
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config.current, {
|
|
1281
1270
|
size: size || 'small',
|
|
1282
1271
|
columns: resultColumns,
|
|
1283
1272
|
rowClassName: "editable-row",
|
|
@@ -1311,7 +1300,7 @@ var EditTable = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
1311
1300
|
|
|
1312
1301
|
return /*#__PURE__*/React.createElement("div", {
|
|
1313
1302
|
className: "lm_editTable_warpper"
|
|
1314
|
-
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config, {
|
|
1303
|
+
}, /*#__PURE__*/React.createElement(Table, Object.assign({}, config.current, {
|
|
1315
1304
|
size: size || 'small',
|
|
1316
1305
|
columns: resultColumns,
|
|
1317
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;
|