ronds-metadata 1.1.75 → 1.1.77
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/comps/EditableRow.js +59 -4
- package/es/comps/Editable/comps/index.less +8 -0
- package/es/comps/Editable/index.d.ts +4 -0
- package/es/comps/Editable/index.js +8 -2
- package/es/comps/Editable/interface.d.ts +2 -0
- package/es/comps/Editable/interface.js +3 -2
- package/es/comps/MetadataForm/DataCell/Select.js +3 -1
- package/package.json +1 -1
@@ -3,17 +3,21 @@ import "antd/es/form/style";
|
|
3
3
|
import _Form from "antd/es/form";
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
5
5
|
import React from 'react';
|
6
|
-
import {
|
6
|
+
import { useDrag, useDrop } from 'react-dnd';
|
7
|
+
import { DND_TYPE, EditableContext } from '../interface';
|
7
8
|
|
8
9
|
var EditableRow = function EditableRow(props) {
|
9
10
|
var record = props.record,
|
10
11
|
index = props.index,
|
11
|
-
className = props.className
|
12
|
+
className = props.className,
|
13
|
+
onMove = props.onMove;
|
12
14
|
|
13
15
|
var _Form$useForm = _Form.useForm(),
|
14
16
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
15
17
|
form = _Form$useForm2[0];
|
16
18
|
|
19
|
+
var ref = React.useRef(null);
|
20
|
+
|
17
21
|
var _ref = React.useContext(EditableContext) || undefined,
|
18
22
|
editableStream = _ref.editableStream;
|
19
23
|
|
@@ -22,6 +26,55 @@ var EditableRow = function EditableRow(props) {
|
|
22
26
|
form.setFieldsValue(record);
|
23
27
|
}, [record]);
|
24
28
|
|
29
|
+
var _useDrop = useDrop({
|
30
|
+
accept: DND_TYPE,
|
31
|
+
collect: function collect(monitor) {
|
32
|
+
var _ref2 = monitor.getItem() || {},
|
33
|
+
dragIndex = _ref2.index;
|
34
|
+
|
35
|
+
if (dragIndex === index || !onMove) {
|
36
|
+
return {};
|
37
|
+
}
|
38
|
+
|
39
|
+
return {
|
40
|
+
isOver: monitor.isOver(),
|
41
|
+
dropClassName: dragIndex < index ? ' drop-over-downward' : ' drop-over-upward'
|
42
|
+
};
|
43
|
+
},
|
44
|
+
drop: function drop(item, monitor) {
|
45
|
+
onMove && onMove({
|
46
|
+
dragIndex: item.index,
|
47
|
+
hoverIndex: index
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}),
|
51
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
52
|
+
_useDrop2$ = _useDrop2[0],
|
53
|
+
isOver = _useDrop2$.isOver,
|
54
|
+
dropClassName = _useDrop2$.dropClassName,
|
55
|
+
drop = _useDrop2[1];
|
56
|
+
|
57
|
+
var _useDrag = useDrag({
|
58
|
+
item: {
|
59
|
+
index: index,
|
60
|
+
type: DND_TYPE
|
61
|
+
},
|
62
|
+
end: function end(item, monitor) {
|
63
|
+
var dropResult = monitor.getDropResult();
|
64
|
+
|
65
|
+
if (item && dropResult) {}
|
66
|
+
},
|
67
|
+
collect: function collect(monitor) {
|
68
|
+
return {
|
69
|
+
isDragging: monitor.isDragging()
|
70
|
+
};
|
71
|
+
}
|
72
|
+
}),
|
73
|
+
_useDrag2 = _slicedToArray(_useDrag, 2),
|
74
|
+
drag = _useDrag2[1];
|
75
|
+
|
76
|
+
onMove && drop(drag(ref));
|
77
|
+
|
25
78
|
var onValuesChange = function onValuesChange(values, allValues) {
|
26
79
|
if (editableStream) {
|
27
80
|
editableStream.next({
|
@@ -50,8 +103,10 @@ var EditableRow = function EditableRow(props) {
|
|
50
103
|
initialValues: record,
|
51
104
|
onValuesChange: onValuesChange,
|
52
105
|
component: false
|
53
|
-
}, /*#__PURE__*/React.createElement("tr", _extends({
|
54
|
-
|
106
|
+
}, /*#__PURE__*/React.createElement("tr", _extends({
|
107
|
+
ref: ref
|
108
|
+
}, props, {
|
109
|
+
className: "".concat(index % 2 === 0 ? 'ant-table-row--even' : 'ant-table-row--odd', " ").concat(className, " ").concat(isOver ? dropClassName : '', " "),
|
55
110
|
style: {
|
56
111
|
height: '30px',
|
57
112
|
fontSize: '13px'
|
@@ -10,6 +10,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
10
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
11
|
import React from 'react';
|
12
12
|
import { pick, isArray } from 'lodash';
|
13
|
+
import { DndProvider } from 'react-dnd';
|
14
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
13
15
|
import EditableCell from './comps/EditableCell';
|
14
16
|
import EditableRow from './comps/EditableRow';
|
15
17
|
import { EditableContext } from './interface';
|
@@ -37,6 +39,7 @@ var Editable = function Editable(props) {
|
|
37
39
|
_props$isAction = props.isAction,
|
38
40
|
isAction = _props$isAction === void 0 ? true : _props$isAction,
|
39
41
|
tableProps = props.tableProps,
|
42
|
+
onMove = props.onMove,
|
40
43
|
onRowClick = props.onRowClick,
|
41
44
|
onButtonCellClick = props.onButtonCellClick,
|
42
45
|
onRowConfirm = props.onRowConfirm,
|
@@ -332,6 +335,8 @@ var Editable = function Editable(props) {
|
|
332
335
|
editHeardCellKey: editHeardCellKey
|
333
336
|
}
|
334
337
|
}
|
338
|
+
}, /*#__PURE__*/React.createElement(DndProvider, {
|
339
|
+
backend: HTML5Backend
|
335
340
|
}, /*#__PURE__*/React.createElement(_Table, _extends({
|
336
341
|
key: _columns.length,
|
337
342
|
className: "ronds-edit-table",
|
@@ -358,10 +363,11 @@ var Editable = function Editable(props) {
|
|
358
363
|
onRow: function onRow(record, index) {
|
359
364
|
return {
|
360
365
|
record: record,
|
361
|
-
index: index
|
366
|
+
index: index,
|
367
|
+
onMove: onMove
|
362
368
|
};
|
363
369
|
}
|
364
|
-
})), (type === 'multiple' || type === 'freedom') && !readonly && isAddRow && defaultValue && /*#__PURE__*/React.createElement(_Button, {
|
370
|
+
}))), (type === 'multiple' || type === 'freedom') && !readonly && isAddRow && defaultValue && /*#__PURE__*/React.createElement(_Button, {
|
365
371
|
block: true,
|
366
372
|
type: "dashed",
|
367
373
|
style: {
|
@@ -30,6 +30,7 @@ export interface EditableRowProps extends React.HTMLAttributes<HTMLElement> {
|
|
30
30
|
rowIndex: number;
|
31
31
|
record?: any;
|
32
32
|
index?: any;
|
33
|
+
onMove?: (data: any) => void;
|
33
34
|
}
|
34
35
|
export declare type InputType = 'bool' | 'number' | 'text' | 'enum' | string;
|
35
36
|
export interface EditColumnsType extends ColumnsType<any> {
|
@@ -68,3 +69,4 @@ export interface IMultipleProps extends ICommonProps {
|
|
68
69
|
}
|
69
70
|
export interface IFreedomProps extends ICommonProps {
|
70
71
|
}
|
72
|
+
export declare const DND_TYPE = "rzDndTableRow";
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/*
|
2
2
|
* @Author: wangxian
|
3
3
|
* @Date: 2022-03-04 15:07:57
|
4
|
-
* @LastEditTime:
|
4
|
+
* @LastEditTime: 2023-01-04 10:38:53
|
5
5
|
*/
|
6
6
|
import React from 'react';
|
7
|
-
export var EditableContext = /*#__PURE__*/React.createContext(null);
|
7
|
+
export var EditableContext = /*#__PURE__*/React.createContext(null);
|
8
|
+
export var DND_TYPE = 'rzDndTableRow';
|
@@ -176,9 +176,11 @@ function Index(props) {
|
|
176
176
|
}
|
177
177
|
|
178
178
|
_enum.forEach(function (it) {
|
179
|
+
var _it$key;
|
180
|
+
|
179
181
|
var obj = {
|
180
182
|
label: it.value,
|
181
|
-
value: (it === null || it === void 0 ? void 0 : it.key)
|
183
|
+
value: (_it$key = it === null || it === void 0 ? void 0 : it.key) !== null && _it$key !== void 0 ? _it$key : it === null || it === void 0 ? void 0 : it.value
|
182
184
|
};
|
183
185
|
|
184
186
|
_options.push(obj);
|