ronds-metadata 1.0.43 → 1.0.44
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/es/comps/Editable/DataCell/Input.js +9 -3
- package/es/comps/Editable/comps/EditableCell.d.ts +1 -0
- package/es/comps/Editable/comps/EditableCell.js +18 -8
- package/es/comps/Editable/comps/index.css +0 -0
- package/es/comps/Editable/index.js +16 -0
- package/es/comps/Editable/utils.d.ts +3 -2
- package/es/comps/Editable/utils.js +19 -3
- package/package.json +1 -1
@@ -6,7 +6,7 @@ import _Input from "antd/es/input";
|
|
6
6
|
/*
|
7
7
|
* @Author: wangxian
|
8
8
|
* @Date: 2022-03-04 14:53:50
|
9
|
-
* @LastEditTime: 2022-03-
|
9
|
+
* @LastEditTime: 2022-03-09 11:13:21
|
10
10
|
*/
|
11
11
|
import React from 'react';
|
12
12
|
import { EditableContext } from '../interface';
|
@@ -20,15 +20,21 @@ function Index(props) {
|
|
20
20
|
editConfig = _ref.editConfig;
|
21
21
|
|
22
22
|
var inputRef = React.useRef();
|
23
|
+
var firstLoadRef = React.useRef(true);
|
23
24
|
React.useEffect(function () {
|
24
25
|
var _editConfig$editCellK, _editConfig$editCellK2;
|
25
26
|
|
26
27
|
if (!inputRef.current) return;
|
27
28
|
|
28
29
|
if (((_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.dataIndex) === dataIndex && ((_editConfig$editCellK2 = editConfig.editCellKey) === null || _editConfig$editCellK2 === void 0 ? void 0 : _editConfig$editCellK2.rowIndex) === rowIndex) {
|
29
|
-
|
30
|
+
if (firstLoadRef.current) {
|
31
|
+
// 选中内容
|
32
|
+
inputRef.current.input.setSelectionRange(0, inputRef.current.state.value.length);
|
33
|
+
firstLoadRef.current = false;
|
34
|
+
} // 设置焦点
|
30
35
|
|
31
|
-
|
36
|
+
|
37
|
+
inputRef.current.focus();
|
32
38
|
}
|
33
39
|
}, [editConfig]);
|
34
40
|
return /*#__PURE__*/React.createElement(_Form.Item, {
|
@@ -5,7 +5,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
5
5
|
var _excluded = ["editable", "record", "editableType", "dataIndex", "rowIndex", "children"];
|
6
6
|
import React from 'react';
|
7
7
|
import { EditableContext } from '../interface';
|
8
|
-
import { getDataCell } from '../utils';
|
8
|
+
import { getDataCell, isFreeEditCell, isFreeEditRow } from '../utils';
|
9
|
+
import "./index.css";
|
9
10
|
|
10
11
|
var EditableCell = function EditableCell(props) {
|
11
12
|
var editable = props.editable,
|
@@ -20,7 +21,7 @@ var EditableCell = function EditableCell(props) {
|
|
20
21
|
editableStream = _ref.editableStream,
|
21
22
|
editConfig = _ref.editConfig;
|
22
23
|
|
23
|
-
var
|
24
|
+
var onCellDoubleClick = function onCellDoubleClick() {
|
24
25
|
if (editConfig === null || editConfig === void 0 ? void 0 : editConfig.curRow) {
|
25
26
|
var _editConfig$curRow;
|
26
27
|
|
@@ -40,18 +41,27 @@ var EditableCell = function EditableCell(props) {
|
|
40
41
|
});
|
41
42
|
};
|
42
43
|
|
44
|
+
var onCellClick = function onCellClick() {
|
45
|
+
if (!isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) {
|
46
|
+
editableStream.next({
|
47
|
+
type: 'editCellKey',
|
48
|
+
payload: {
|
49
|
+
dataIndex: undefined,
|
50
|
+
rowIndex: undefined
|
51
|
+
}
|
52
|
+
});
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
43
56
|
if (editableType === 'single') {
|
44
57
|
return /*#__PURE__*/React.createElement("td", restProps, editable && editConfig.curRow === rowIndex ? getDataCell(props) : children);
|
45
58
|
}
|
46
59
|
|
47
60
|
if (editableType === 'freedom') {
|
48
|
-
var _editConfig$curRow2, _editConfig$editCellK, _editConfig$editCellK2;
|
49
|
-
|
50
|
-
var isAddRow = editable && ((_editConfig$curRow2 = editConfig.curRow) === null || _editConfig$curRow2 === void 0 ? void 0 : _editConfig$curRow2.toString().split(',').indexOf("".concat(rowIndex))) > -1;
|
51
|
-
var isCell = editable && ((_editConfig$editCellK = editConfig.editCellKey) === null || _editConfig$editCellK === void 0 ? void 0 : _editConfig$editCellK.dataIndex) === dataIndex && ((_editConfig$editCellK2 = editConfig.editCellKey) === null || _editConfig$editCellK2 === void 0 ? void 0 : _editConfig$editCellK2.rowIndex) === rowIndex;
|
52
61
|
return /*#__PURE__*/React.createElement("td", _extends({
|
53
|
-
onDoubleClick:
|
54
|
-
|
62
|
+
onDoubleClick: onCellDoubleClick,
|
63
|
+
onClick: onCellClick
|
64
|
+
}, restProps), editable && (isFreeEditRow(editConfig.curRow, rowIndex) || isFreeEditCell(editConfig.editCellKey, dataIndex, rowIndex)) ? getDataCell(props) : children);
|
55
65
|
}
|
56
66
|
|
57
67
|
return /*#__PURE__*/React.createElement("td", restProps, editable ? getDataCell(props) : children);
|
File without changes
|
@@ -15,6 +15,7 @@ import EditableCell from './comps/EditableCell';
|
|
15
15
|
import EditableRow from './comps/EditableRow';
|
16
16
|
import { EditableContext } from './interface';
|
17
17
|
import EditableAction from './comps/EditableAction';
|
18
|
+
import { isFreeEditRow, removeCurKeyFromEditRow } from './utils';
|
18
19
|
|
19
20
|
var Editable = function Editable(props) {
|
20
21
|
var _props$type = props.type,
|
@@ -143,6 +144,21 @@ var Editable = function Editable(props) {
|
|
143
144
|
|
144
145
|
if (type === 'freedom') {
|
145
146
|
// 正在全行编辑的直接删除,不需要回调
|
147
|
+
if (isFreeEditRow(editRowKeyRef.current, data.payload._rowKey_)) {
|
148
|
+
var _records4 = recordsRef.current;
|
149
|
+
|
150
|
+
_records4.splice(data.payload._rowKey_, 1);
|
151
|
+
|
152
|
+
setRecords(_toConsumableArray(_records4));
|
153
|
+
recordsRef.current = _records4; // 移除当前的行的编辑状态
|
154
|
+
|
155
|
+
var _editRowKey = removeCurKeyFromEditRow(editRowKeyRef.current, data.payload._rowKey_);
|
156
|
+
|
157
|
+
setEditRowkey(_editRowKey);
|
158
|
+
editRowKeyRef.current = _editRowKey;
|
159
|
+
return;
|
160
|
+
}
|
161
|
+
|
146
162
|
onRowDelete && onRowDelete(data.payload);
|
147
163
|
}
|
148
164
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { EditableCellProps } from './interface';
|
2
2
|
export declare function getDataCell(item: EditableCellProps): JSX.Element;
|
3
|
-
export declare function isFreeEditRow():
|
4
|
-
export declare function isFreeEditCell():
|
3
|
+
export declare function isFreeEditRow(curRow: any, rowIndex: number): boolean;
|
4
|
+
export declare function isFreeEditCell(editCellKey: any, dataIndex: string, rowIndex: number): boolean;
|
5
|
+
export declare function removeCurKeyFromEditRow(editRowKey: any, curKey: number): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: wangxian
|
3
3
|
* @Date: 2022-03-04 14:59:04
|
4
|
-
* @LastEditTime: 2022-03-09
|
4
|
+
* @LastEditTime: 2022-03-09 10:42:38
|
5
5
|
*/
|
6
6
|
import React from 'react';
|
7
7
|
import Input from './DataCell/Input';
|
@@ -22,5 +22,21 @@ export function getDataCell(item) {
|
|
22
22
|
|
23
23
|
return null;
|
24
24
|
}
|
25
|
-
export function isFreeEditRow() {
|
26
|
-
|
25
|
+
export function isFreeEditRow(curRow, rowIndex) {
|
26
|
+
return (curRow === null || curRow === void 0 ? void 0 : curRow.toString().split(',').indexOf("".concat(rowIndex))) > -1;
|
27
|
+
}
|
28
|
+
export function isFreeEditCell(editCellKey, dataIndex, rowIndex) {
|
29
|
+
return (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.dataIndex) === dataIndex && (editCellKey === null || editCellKey === void 0 ? void 0 : editCellKey.rowIndex) === rowIndex;
|
30
|
+
}
|
31
|
+
export function removeCurKeyFromEditRow(editRowKey, curKey) {
|
32
|
+
var keys = editRowKey.toString().split(',');
|
33
|
+
var res = [];
|
34
|
+
keys.forEach(function (v) {
|
35
|
+
if (parseInt(v) > curKey) {
|
36
|
+
res.push(parseInt(v) - 1);
|
37
|
+
} else if (v !== "".concat(curKey)) {
|
38
|
+
res.push(v);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
return res.toString();
|
42
|
+
}
|