@zat-design/sisyphus-react 3.6.10-beta.1 → 3.6.10-beta.3
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/ProEditTable/utils/index.js +16 -11
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +1 -4
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +30 -100
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +1 -7
- package/es/ProTable/index.js +2 -8
- package/es/ProTable/propsType.d.ts +6 -9
- package/lib/ProEditTable/utils/index.js +15 -10
- package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +1 -4
- package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +30 -100
- package/lib/ProTable/components/RcTable/components/DraggableTable/index.js +1 -7
- package/lib/ProTable/index.js +2 -8
- package/lib/ProTable/propsType.d.ts +6 -9
- package/package.json +1 -1
- package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +0 -241
- package/coverage/lcov-report/src/.umi/core/history.ts.html +0 -148
- package/coverage/lcov-report/src/.umi/core/index.html +0 -206
- package/coverage/lcov-report/src/.umi/core/plugin.ts.html +0 -109
- package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +0 -160
- package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +0 -97
- package/coverage/lcov-report/src/.umi/core/routes.ts.html +0 -26050
- package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +0 -112
- package/coverage/lcov-report/src/.umi/dumi/demos/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +0 -6340
- package/coverage/lcov-report/src/.umi/dumi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +0 -109
- package/coverage/lcov-report/src/.umi/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +0 -172
- package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +0 -94
- package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +0 -196
- package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +0 -106
- package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +0 -88
- package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +0 -124
- package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +0 -1246
- package/coverage/lcov-report/src/.umi/plugin-locale/index.html +0 -161
- package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +0 -268
- package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +0 -778
- package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +0 -115
- package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +0 -202
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +0 -97
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +0 -142
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +0 -334
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/index.html +0 -146
- package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +0 -121
- package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +0 -298
- package/coverage/lcov-report/src/.umi/plugin-request/index.html +0 -116
- package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +0 -919
- package/coverage/lcov-report/src/.umi/umi.ts.html +0 -268
|
@@ -13,7 +13,7 @@ var _excluded = ["type", "label", "show", "needConfirm", "onHandle", "onClick"],
|
|
|
13
13
|
_excluded2 = ["title", "icon"];
|
|
14
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
15
|
import React from 'react';
|
|
16
|
-
import { cloneDeep, isArray, isBoolean, isEqual } from 'lodash';
|
|
16
|
+
import { cloneDeep, cloneDeepWith, isArray, isBoolean, isEqual } from 'lodash';
|
|
17
17
|
import classnames from 'classnames';
|
|
18
18
|
import { ReactSVG } from 'react-svg';
|
|
19
19
|
import { tools } from '@zat-design/utils';
|
|
@@ -25,16 +25,21 @@ import tipSvg from '../../assets/tip.svg';
|
|
|
25
25
|
import locale from '../../locale';
|
|
26
26
|
// 渲染操作栏
|
|
27
27
|
var getActionColumn = function getActionColumn(config) {
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
var _cloneDeepWith = cloneDeepWith(config, function (value) {
|
|
29
|
+
if ( /*#__PURE__*/React.isValidElement(value)) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
disabled = _cloneDeepWith.disabled,
|
|
34
|
+
name = _cloneDeepWith.name,
|
|
35
|
+
form = _cloneDeepWith.form,
|
|
36
|
+
virtualKey = _cloneDeepWith.virtualKey,
|
|
37
|
+
validateKeys = _cloneDeepWith.validateKeys,
|
|
38
|
+
actionWidth = _cloneDeepWith.actionWidth,
|
|
39
|
+
actionProps = _cloneDeepWith.actionProps,
|
|
40
|
+
page = _cloneDeepWith.page,
|
|
41
|
+
rowDisabled = _cloneDeepWith.rowDisabled,
|
|
42
|
+
actionDirection = _cloneDeepWith.actionDirection;
|
|
38
43
|
var pageNum = tools.calc(page.pageNum, '-', 1);
|
|
39
44
|
var firstIndex = tools.calc(pageNum, '*', page.pageSize);
|
|
40
45
|
// actionProps配置为false 默认不插入
|
package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare const Row: FC<RowProps>;
|
|
8
|
-
declare const DndWrapper: ({ draggable, value, onChange, disabled, children, rowKey, onDragStartGuard,
|
|
8
|
+
declare const DndWrapper: ({ draggable, value, onChange, disabled, children, rowKey, onDragStartGuard, onDragEndGuard, }: {
|
|
9
9
|
draggable: any;
|
|
10
10
|
value: any;
|
|
11
11
|
onChange: any;
|
|
@@ -13,9 +13,6 @@ declare const DndWrapper: ({ draggable, value, onChange, disabled, children, row
|
|
|
13
13
|
children: any;
|
|
14
14
|
rowKey: any;
|
|
15
15
|
onDragStartGuard: any;
|
|
16
|
-
onDragMoveGuard: any;
|
|
17
|
-
onDragOverGuard: any;
|
|
18
16
|
onDragEndGuard: any;
|
|
19
|
-
onDragCancelGuard: any;
|
|
20
17
|
}) => any;
|
|
21
18
|
export default DndWrapper;
|
package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js
CHANGED
|
@@ -72,90 +72,49 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
72
72
|
children = _ref2.children,
|
|
73
73
|
rowKey = _ref2.rowKey,
|
|
74
74
|
onDragStartGuard = _ref2.onDragStartGuard,
|
|
75
|
-
|
|
76
|
-
onDragOverGuard = _ref2.onDragOverGuard,
|
|
77
|
-
onDragEndGuard = _ref2.onDragEndGuard,
|
|
78
|
-
onDragCancelGuard = _ref2.onDragCancelGuard;
|
|
75
|
+
onDragEndGuard = _ref2.onDragEndGuard;
|
|
79
76
|
var onDragStart = /*#__PURE__*/function () {
|
|
80
|
-
var
|
|
77
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
|
|
78
|
+
var active, transformedValue, activeObject;
|
|
81
79
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
82
80
|
while (1) switch (_context.prev = _context.next) {
|
|
83
81
|
case 0:
|
|
82
|
+
active = _ref3.active;
|
|
84
83
|
if (!(onDragStartGuard && isFunction(onDragStartGuard))) {
|
|
85
|
-
_context.next =
|
|
84
|
+
_context.next = 6;
|
|
86
85
|
break;
|
|
87
86
|
}
|
|
88
|
-
|
|
87
|
+
// 为数据源划分层级及parentId
|
|
88
|
+
transformedValue = addLevelAndParentId(value, rowKey);
|
|
89
|
+
activeObject = treeNodeFind(transformedValue, function (t) {
|
|
90
|
+
return t.rowKey === active.id;
|
|
91
|
+
});
|
|
92
|
+
_context.next = 6;
|
|
89
93
|
return onDragStartGuard({
|
|
90
|
-
|
|
94
|
+
activeObject: activeObject,
|
|
95
|
+
currentDataSource: value
|
|
91
96
|
});
|
|
92
|
-
case
|
|
97
|
+
case 6:
|
|
93
98
|
case "end":
|
|
94
99
|
return _context.stop();
|
|
95
100
|
}
|
|
96
101
|
}, _callee);
|
|
97
102
|
}));
|
|
98
103
|
return function onDragStart(_x) {
|
|
99
|
-
return _ref3.apply(this, arguments);
|
|
100
|
-
};
|
|
101
|
-
}();
|
|
102
|
-
var onDragMove = /*#__PURE__*/function () {
|
|
103
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
|
|
104
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
105
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
106
|
-
case 0:
|
|
107
|
-
if (!(onDragMoveGuard && isFunction(onDragMoveGuard))) {
|
|
108
|
-
_context2.next = 3;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
_context2.next = 3;
|
|
112
|
-
return onDragMoveGuard({
|
|
113
|
-
event: event
|
|
114
|
-
});
|
|
115
|
-
case 3:
|
|
116
|
-
case "end":
|
|
117
|
-
return _context2.stop();
|
|
118
|
-
}
|
|
119
|
-
}, _callee2);
|
|
120
|
-
}));
|
|
121
|
-
return function onDragMove(_x2) {
|
|
122
104
|
return _ref4.apply(this, arguments);
|
|
123
105
|
};
|
|
124
106
|
}();
|
|
125
|
-
var onDragOver = /*#__PURE__*/function () {
|
|
126
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(event) {
|
|
127
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
128
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
129
|
-
case 0:
|
|
130
|
-
if (!(onDragOverGuard && isFunction(onDragOverGuard))) {
|
|
131
|
-
_context3.next = 3;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
_context3.next = 3;
|
|
135
|
-
return onDragOverGuard({
|
|
136
|
-
event: event
|
|
137
|
-
});
|
|
138
|
-
case 3:
|
|
139
|
-
case "end":
|
|
140
|
-
return _context3.stop();
|
|
141
|
-
}
|
|
142
|
-
}, _callee3);
|
|
143
|
-
}));
|
|
144
|
-
return function onDragOver(_x3) {
|
|
145
|
-
return _ref5.apply(this, arguments);
|
|
146
|
-
};
|
|
147
|
-
}();
|
|
148
107
|
var onDragEnd = /*#__PURE__*/function () {
|
|
149
|
-
var
|
|
108
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
|
|
150
109
|
var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
|
|
151
|
-
return _regeneratorRuntime().wrap(function
|
|
152
|
-
while (1) switch (
|
|
110
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
111
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
153
112
|
case 0:
|
|
154
|
-
active =
|
|
113
|
+
active = _ref5.active, over = _ref5.over;
|
|
155
114
|
// 为数据源划分层级及parentId
|
|
156
115
|
transformedValue = addLevelAndParentId(value, rowKey); // 同一level层级的且parentId相同的,可以互相之间拖拽替换
|
|
157
116
|
if (!(active.id !== (over === null || over === void 0 ? void 0 : over.id))) {
|
|
158
|
-
|
|
117
|
+
_context2.next = 15;
|
|
159
118
|
break;
|
|
160
119
|
}
|
|
161
120
|
activeObject = treeNodeFind(transformedValue, function (t) {
|
|
@@ -165,28 +124,25 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
165
124
|
return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
|
166
125
|
});
|
|
167
126
|
if (!(activeObject && overObject)) {
|
|
168
|
-
|
|
127
|
+
_context2.next = 15;
|
|
169
128
|
break;
|
|
170
129
|
}
|
|
171
130
|
activeLevel = activeObject.level, activeParentId = activeObject.parentId;
|
|
172
131
|
overLevel = overObject.level, overParentId = overObject.parentId; // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
|
|
173
132
|
if (!(onDragEndGuard && isFunction(onDragEndGuard))) {
|
|
174
|
-
|
|
133
|
+
_context2.next = 14;
|
|
175
134
|
break;
|
|
176
135
|
}
|
|
177
|
-
|
|
136
|
+
_context2.next = 11;
|
|
178
137
|
return onDragEndGuard({
|
|
179
138
|
activeObject: activeObject,
|
|
180
139
|
overObject: overObject,
|
|
181
|
-
currentDataSource: value
|
|
182
|
-
transformTreeToArray: transformTreeToArray,
|
|
183
|
-
arrayMove: arrayMove,
|
|
184
|
-
createTreeFromArray: createTreeFromArray
|
|
140
|
+
currentDataSource: value
|
|
185
141
|
});
|
|
186
142
|
case 11:
|
|
187
|
-
nextDataSource =
|
|
143
|
+
nextDataSource = _context2.sent;
|
|
188
144
|
onChange(nextDataSource !== null && nextDataSource !== void 0 ? nextDataSource : []);
|
|
189
|
-
return
|
|
145
|
+
return _context2.abrupt("return");
|
|
190
146
|
case 14:
|
|
191
147
|
if (activeLevel === overLevel && activeParentId === overParentId) {
|
|
192
148
|
// 将树平铺
|
|
@@ -210,35 +166,12 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
210
166
|
}
|
|
211
167
|
case 15:
|
|
212
168
|
case "end":
|
|
213
|
-
return
|
|
214
|
-
}
|
|
215
|
-
}, _callee4);
|
|
216
|
-
}));
|
|
217
|
-
return function onDragEnd(_x4) {
|
|
218
|
-
return _ref7.apply(this, arguments);
|
|
219
|
-
};
|
|
220
|
-
}();
|
|
221
|
-
var onDragCancel = /*#__PURE__*/function () {
|
|
222
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
|
|
223
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
224
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
225
|
-
case 0:
|
|
226
|
-
if (!(onDragCancelGuard && isFunction(onDragCancelGuard))) {
|
|
227
|
-
_context5.next = 3;
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
_context5.next = 3;
|
|
231
|
-
return onDragCancelGuard({
|
|
232
|
-
event: event
|
|
233
|
-
});
|
|
234
|
-
case 3:
|
|
235
|
-
case "end":
|
|
236
|
-
return _context5.stop();
|
|
169
|
+
return _context2.stop();
|
|
237
170
|
}
|
|
238
|
-
},
|
|
171
|
+
}, _callee2);
|
|
239
172
|
}));
|
|
240
|
-
return function
|
|
241
|
-
return
|
|
173
|
+
return function onDragEnd(_x2) {
|
|
174
|
+
return _ref6.apply(this, arguments);
|
|
242
175
|
};
|
|
243
176
|
}();
|
|
244
177
|
// 将树平铺
|
|
@@ -248,11 +181,8 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
248
181
|
});
|
|
249
182
|
});
|
|
250
183
|
return draggable && !disabled ? _jsx(DndContext, {
|
|
251
|
-
onDragEnd: onDragEnd,
|
|
252
184
|
onDragStart: onDragStart,
|
|
253
|
-
|
|
254
|
-
onDragOver: onDragOver,
|
|
255
|
-
onDragCancel: onDragCancel,
|
|
185
|
+
onDragEnd: onDragEnd,
|
|
256
186
|
collisionDetection: closestCorners,
|
|
257
187
|
children: _jsx(SortableContext, {
|
|
258
188
|
items: (flatTree === null || flatTree === void 0 ? void 0 : (_flatTree$ = flatTree[0]) === null || _flatTree$ === void 0 ? void 0 : _flatTree$.rowKey) ? flatTree.map(function (i) {
|
|
@@ -32,10 +32,7 @@ var DraggableTable = function DraggableTable(_ref) {
|
|
|
32
32
|
draggable = draggableProps.draggable,
|
|
33
33
|
rowKey = draggableProps.rowKey,
|
|
34
34
|
onDragStartGuard = draggableProps.onDragStartGuard,
|
|
35
|
-
|
|
36
|
-
onDragOverGuard = draggableProps.onDragOverGuard,
|
|
37
|
-
onDragEndGuard = draggableProps.onDragEndGuard,
|
|
38
|
-
onDragCancelGuard = draggableProps.onDragCancelGuard;
|
|
35
|
+
onDragEndGuard = draggableProps.onDragEndGuard;
|
|
39
36
|
return _jsx(DndWrapper, {
|
|
40
37
|
value: dataSource !== null && dataSource !== void 0 ? dataSource : [],
|
|
41
38
|
onChange: onChange,
|
|
@@ -43,10 +40,7 @@ var DraggableTable = function DraggableTable(_ref) {
|
|
|
43
40
|
draggable: draggable,
|
|
44
41
|
rowKey: rowKey,
|
|
45
42
|
onDragStartGuard: onDragStartGuard,
|
|
46
|
-
onDragMoveGuard: onDragMoveGuard,
|
|
47
|
-
onDragOverGuard: onDragOverGuard,
|
|
48
43
|
onDragEndGuard: onDragEndGuard,
|
|
49
|
-
onDragCancelGuard: onDragCancelGuard,
|
|
50
44
|
children: _jsx(_Table, _objectSpread(_objectSpread({
|
|
51
45
|
className: "pro-edit-table-drag",
|
|
52
46
|
components: {
|
package/es/ProTable/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
7
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
8
|
-
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "originalDataSource", "onDragStart", "
|
|
8
|
+
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "originalDataSource", "onDragStart", "onDragEnd"],
|
|
9
9
|
_excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
|
|
10
10
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { useEffect, useMemo, useState, createContext } from 'react';
|
|
@@ -54,10 +54,7 @@ function ProTable(props) {
|
|
|
54
54
|
emptyText = _props$emptyText === void 0 ? locale === null || locale === void 0 ? void 0 : (_locale$ProTable = locale.ProTable) === null || _locale$ProTable === void 0 ? void 0 : _locale$ProTable.noData : _props$emptyText,
|
|
55
55
|
originalDataSource = props.originalDataSource,
|
|
56
56
|
onDragStartGuard = props.onDragStart,
|
|
57
|
-
onDragMoveGuard = props.onDragMove,
|
|
58
|
-
onDragOverGuard = props.onDragOver,
|
|
59
57
|
onDragEndGuard = props.onDragEnd,
|
|
60
|
-
onDragCancelGuard = props.onDragCancel,
|
|
61
58
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
62
59
|
var quickTableConfig = quickConfig ? _objectSpread({
|
|
63
60
|
columnConfig: true,
|
|
@@ -359,10 +356,7 @@ function ProTable(props) {
|
|
|
359
356
|
draggable: draggable,
|
|
360
357
|
rowKey: rowKey,
|
|
361
358
|
onDragStartGuard: onDragStartGuard,
|
|
362
|
-
|
|
363
|
-
onDragOverGuard: onDragOverGuard,
|
|
364
|
-
onDragEndGuard: onDragEndGuard,
|
|
365
|
-
onDragCancelGuard: onDragCancelGuard
|
|
359
|
+
onDragEndGuard: onDragEndGuard
|
|
366
360
|
},
|
|
367
361
|
tableProps: {
|
|
368
362
|
value: _dataSource,
|
|
@@ -3,7 +3,6 @@ import { TableProps } from 'antd/es/table/Table';
|
|
|
3
3
|
import { ColumnType, GetRowKey, RowSelectionType } from 'antd/es/table/interface';
|
|
4
4
|
import { FormInstance } from 'antd';
|
|
5
5
|
import type { TooltipProps } from 'antd';
|
|
6
|
-
import type { DragStartEvent, DragMoveEvent, DragOverEvent, DragCancelEvent } from '@dnd-kit/core';
|
|
7
6
|
interface SummaryColumnProps {
|
|
8
7
|
key: string | string[];
|
|
9
8
|
index: number;
|
|
@@ -52,11 +51,12 @@ export interface DragCommonGuardProps<T> {
|
|
|
52
51
|
}
|
|
53
52
|
export interface DragEndGuardProps {
|
|
54
53
|
activeObject: any;
|
|
55
|
-
overObject
|
|
54
|
+
overObject?: any;
|
|
55
|
+
currentDataSource: any[];
|
|
56
|
+
}
|
|
57
|
+
export interface DragStartGuardProps {
|
|
58
|
+
activeObject: any;
|
|
56
59
|
currentDataSource: any[];
|
|
57
|
-
transformTreeToArray: (tree: any[]) => any[];
|
|
58
|
-
arrayMove: (array: any[], from: number, to: number) => any[];
|
|
59
|
-
createTreeFromArray: (array: any[], options: CreateTreeFromArrayOptions) => any[];
|
|
60
60
|
}
|
|
61
61
|
export interface ProTableProps<T = any> extends Omit<TableProps<any>, 'summary' | 'columns'> {
|
|
62
62
|
tableId?: string;
|
|
@@ -87,10 +87,7 @@ export interface ProTableProps<T = any> extends Omit<TableProps<any>, 'summary'
|
|
|
87
87
|
/**
|
|
88
88
|
* 拖拽额外配置
|
|
89
89
|
*/
|
|
90
|
-
onDragStart?:
|
|
91
|
-
onDragMove?: DragCommonGuardProps<DragMoveEvent>;
|
|
92
|
-
onDragOver?: DragCommonGuardProps<DragOverEvent>;
|
|
93
|
-
onDragCancel?: DragCommonGuardProps<DragCancelEvent>;
|
|
90
|
+
onDragStart?: DragStartGuardProps;
|
|
94
91
|
onDragEnd?: DragEndGuardProps;
|
|
95
92
|
}
|
|
96
93
|
export type ProTableValueType = 'percentage' | 'permillage' | 'thousandth' | 'datePicker' | 'enumName' | 'enumCodeName' | 'address' | 'thousandthCNY' | 'date' | 'dateTime' | 'dateStartTime' | 'dateEndTime' | 'dateStartEndTime';
|
|
@@ -29,16 +29,21 @@ var _excluded = ["type", "label", "show", "needConfirm", "onHandle", "onClick"],
|
|
|
29
29
|
_excluded2 = ["title", "icon"];
|
|
30
30
|
// 渲染操作栏
|
|
31
31
|
var getActionColumn = function getActionColumn(config) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
var _cloneDeepWith = (0, _lodash.cloneDeepWith)(config, function (value) {
|
|
33
|
+
if ( /*#__PURE__*/_react.default.isValidElement(value)) {
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
disabled = _cloneDeepWith.disabled,
|
|
38
|
+
name = _cloneDeepWith.name,
|
|
39
|
+
form = _cloneDeepWith.form,
|
|
40
|
+
virtualKey = _cloneDeepWith.virtualKey,
|
|
41
|
+
validateKeys = _cloneDeepWith.validateKeys,
|
|
42
|
+
actionWidth = _cloneDeepWith.actionWidth,
|
|
43
|
+
actionProps = _cloneDeepWith.actionProps,
|
|
44
|
+
page = _cloneDeepWith.page,
|
|
45
|
+
rowDisabled = _cloneDeepWith.rowDisabled,
|
|
46
|
+
actionDirection = _cloneDeepWith.actionDirection;
|
|
42
47
|
var pageNum = _utils.tools.calc(page.pageNum, '-', 1);
|
|
43
48
|
var firstIndex = _utils.tools.calc(pageNum, '*', page.pageSize);
|
|
44
49
|
// actionProps配置为false 默认不插入
|
package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare const Row: FC<RowProps>;
|
|
8
|
-
declare const DndWrapper: ({ draggable, value, onChange, disabled, children, rowKey, onDragStartGuard,
|
|
8
|
+
declare const DndWrapper: ({ draggable, value, onChange, disabled, children, rowKey, onDragStartGuard, onDragEndGuard, }: {
|
|
9
9
|
draggable: any;
|
|
10
10
|
value: any;
|
|
11
11
|
onChange: any;
|
|
@@ -13,9 +13,6 @@ declare const DndWrapper: ({ draggable, value, onChange, disabled, children, row
|
|
|
13
13
|
children: any;
|
|
14
14
|
rowKey: any;
|
|
15
15
|
onDragStartGuard: any;
|
|
16
|
-
onDragMoveGuard: any;
|
|
17
|
-
onDragOverGuard: any;
|
|
18
16
|
onDragEndGuard: any;
|
|
19
|
-
onDragCancelGuard: any;
|
|
20
17
|
}) => any;
|
|
21
18
|
export default DndWrapper;
|
package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js
CHANGED
|
@@ -79,90 +79,49 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
79
79
|
children = _ref2.children,
|
|
80
80
|
rowKey = _ref2.rowKey,
|
|
81
81
|
onDragStartGuard = _ref2.onDragStartGuard,
|
|
82
|
-
|
|
83
|
-
onDragOverGuard = _ref2.onDragOverGuard,
|
|
84
|
-
onDragEndGuard = _ref2.onDragEndGuard,
|
|
85
|
-
onDragCancelGuard = _ref2.onDragCancelGuard;
|
|
82
|
+
onDragEndGuard = _ref2.onDragEndGuard;
|
|
86
83
|
var onDragStart = /*#__PURE__*/function () {
|
|
87
|
-
var
|
|
84
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(_ref3) {
|
|
85
|
+
var active, transformedValue, activeObject;
|
|
88
86
|
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
89
87
|
while (1) switch (_context.prev = _context.next) {
|
|
90
88
|
case 0:
|
|
89
|
+
active = _ref3.active;
|
|
91
90
|
if (!(onDragStartGuard && (0, _lodash.isFunction)(onDragStartGuard))) {
|
|
92
|
-
_context.next =
|
|
91
|
+
_context.next = 6;
|
|
93
92
|
break;
|
|
94
93
|
}
|
|
95
|
-
|
|
94
|
+
// 为数据源划分层级及parentId
|
|
95
|
+
transformedValue = (0, _index.addLevelAndParentId)(value, rowKey);
|
|
96
|
+
activeObject = (0, _index.treeNodeFind)(transformedValue, function (t) {
|
|
97
|
+
return t.rowKey === active.id;
|
|
98
|
+
});
|
|
99
|
+
_context.next = 6;
|
|
96
100
|
return onDragStartGuard({
|
|
97
|
-
|
|
101
|
+
activeObject: activeObject,
|
|
102
|
+
currentDataSource: value
|
|
98
103
|
});
|
|
99
|
-
case
|
|
104
|
+
case 6:
|
|
100
105
|
case "end":
|
|
101
106
|
return _context.stop();
|
|
102
107
|
}
|
|
103
108
|
}, _callee);
|
|
104
109
|
}));
|
|
105
110
|
return function onDragStart(_x) {
|
|
106
|
-
return _ref3.apply(this, arguments);
|
|
107
|
-
};
|
|
108
|
-
}();
|
|
109
|
-
var onDragMove = /*#__PURE__*/function () {
|
|
110
|
-
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(event) {
|
|
111
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
112
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
113
|
-
case 0:
|
|
114
|
-
if (!(onDragMoveGuard && (0, _lodash.isFunction)(onDragMoveGuard))) {
|
|
115
|
-
_context2.next = 3;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
_context2.next = 3;
|
|
119
|
-
return onDragMoveGuard({
|
|
120
|
-
event: event
|
|
121
|
-
});
|
|
122
|
-
case 3:
|
|
123
|
-
case "end":
|
|
124
|
-
return _context2.stop();
|
|
125
|
-
}
|
|
126
|
-
}, _callee2);
|
|
127
|
-
}));
|
|
128
|
-
return function onDragMove(_x2) {
|
|
129
111
|
return _ref4.apply(this, arguments);
|
|
130
112
|
};
|
|
131
113
|
}();
|
|
132
|
-
var onDragOver = /*#__PURE__*/function () {
|
|
133
|
-
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee3(event) {
|
|
134
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee3$(_context3) {
|
|
135
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
136
|
-
case 0:
|
|
137
|
-
if (!(onDragOverGuard && (0, _lodash.isFunction)(onDragOverGuard))) {
|
|
138
|
-
_context3.next = 3;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
_context3.next = 3;
|
|
142
|
-
return onDragOverGuard({
|
|
143
|
-
event: event
|
|
144
|
-
});
|
|
145
|
-
case 3:
|
|
146
|
-
case "end":
|
|
147
|
-
return _context3.stop();
|
|
148
|
-
}
|
|
149
|
-
}, _callee3);
|
|
150
|
-
}));
|
|
151
|
-
return function onDragOver(_x3) {
|
|
152
|
-
return _ref5.apply(this, arguments);
|
|
153
|
-
};
|
|
154
|
-
}();
|
|
155
114
|
var onDragEnd = /*#__PURE__*/function () {
|
|
156
|
-
var
|
|
115
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee2(_ref5) {
|
|
157
116
|
var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
|
|
158
|
-
return (0, _regeneratorRuntime2.default)().wrap(function
|
|
159
|
-
while (1) switch (
|
|
117
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee2$(_context2) {
|
|
118
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
160
119
|
case 0:
|
|
161
|
-
active =
|
|
120
|
+
active = _ref5.active, over = _ref5.over;
|
|
162
121
|
// 为数据源划分层级及parentId
|
|
163
122
|
transformedValue = (0, _index.addLevelAndParentId)(value, rowKey); // 同一level层级的且parentId相同的,可以互相之间拖拽替换
|
|
164
123
|
if (!(active.id !== (over === null || over === void 0 ? void 0 : over.id))) {
|
|
165
|
-
|
|
124
|
+
_context2.next = 15;
|
|
166
125
|
break;
|
|
167
126
|
}
|
|
168
127
|
activeObject = (0, _index.treeNodeFind)(transformedValue, function (t) {
|
|
@@ -172,28 +131,25 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
172
131
|
return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
|
173
132
|
});
|
|
174
133
|
if (!(activeObject && overObject)) {
|
|
175
|
-
|
|
134
|
+
_context2.next = 15;
|
|
176
135
|
break;
|
|
177
136
|
}
|
|
178
137
|
activeLevel = activeObject.level, activeParentId = activeObject.parentId;
|
|
179
138
|
overLevel = overObject.level, overParentId = overObject.parentId; // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
|
|
180
139
|
if (!(onDragEndGuard && (0, _lodash.isFunction)(onDragEndGuard))) {
|
|
181
|
-
|
|
140
|
+
_context2.next = 14;
|
|
182
141
|
break;
|
|
183
142
|
}
|
|
184
|
-
|
|
143
|
+
_context2.next = 11;
|
|
185
144
|
return onDragEndGuard({
|
|
186
145
|
activeObject: activeObject,
|
|
187
146
|
overObject: overObject,
|
|
188
|
-
currentDataSource: value
|
|
189
|
-
transformTreeToArray: _index.transformTreeToArray,
|
|
190
|
-
arrayMove: _sortable.arrayMove,
|
|
191
|
-
createTreeFromArray: _index.createTreeFromArray
|
|
147
|
+
currentDataSource: value
|
|
192
148
|
});
|
|
193
149
|
case 11:
|
|
194
|
-
nextDataSource =
|
|
150
|
+
nextDataSource = _context2.sent;
|
|
195
151
|
onChange(nextDataSource !== null && nextDataSource !== void 0 ? nextDataSource : []);
|
|
196
|
-
return
|
|
152
|
+
return _context2.abrupt("return");
|
|
197
153
|
case 14:
|
|
198
154
|
if (activeLevel === overLevel && activeParentId === overParentId) {
|
|
199
155
|
// 将树平铺
|
|
@@ -217,35 +173,12 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
217
173
|
}
|
|
218
174
|
case 15:
|
|
219
175
|
case "end":
|
|
220
|
-
return
|
|
221
|
-
}
|
|
222
|
-
}, _callee4);
|
|
223
|
-
}));
|
|
224
|
-
return function onDragEnd(_x4) {
|
|
225
|
-
return _ref7.apply(this, arguments);
|
|
226
|
-
};
|
|
227
|
-
}();
|
|
228
|
-
var onDragCancel = /*#__PURE__*/function () {
|
|
229
|
-
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee5(event) {
|
|
230
|
-
return (0, _regeneratorRuntime2.default)().wrap(function _callee5$(_context5) {
|
|
231
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
232
|
-
case 0:
|
|
233
|
-
if (!(onDragCancelGuard && (0, _lodash.isFunction)(onDragCancelGuard))) {
|
|
234
|
-
_context5.next = 3;
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
_context5.next = 3;
|
|
238
|
-
return onDragCancelGuard({
|
|
239
|
-
event: event
|
|
240
|
-
});
|
|
241
|
-
case 3:
|
|
242
|
-
case "end":
|
|
243
|
-
return _context5.stop();
|
|
176
|
+
return _context2.stop();
|
|
244
177
|
}
|
|
245
|
-
},
|
|
178
|
+
}, _callee2);
|
|
246
179
|
}));
|
|
247
|
-
return function
|
|
248
|
-
return
|
|
180
|
+
return function onDragEnd(_x2) {
|
|
181
|
+
return _ref6.apply(this, arguments);
|
|
249
182
|
};
|
|
250
183
|
}();
|
|
251
184
|
// 将树平铺
|
|
@@ -255,11 +188,8 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
255
188
|
});
|
|
256
189
|
});
|
|
257
190
|
return draggable && !disabled ? (0, _jsxRuntime.jsx)(_core.DndContext, {
|
|
258
|
-
onDragEnd: onDragEnd,
|
|
259
191
|
onDragStart: onDragStart,
|
|
260
|
-
|
|
261
|
-
onDragOver: onDragOver,
|
|
262
|
-
onDragCancel: onDragCancel,
|
|
192
|
+
onDragEnd: onDragEnd,
|
|
263
193
|
collisionDetection: _core.closestCorners,
|
|
264
194
|
children: (0, _jsxRuntime.jsx)(_sortable.SortableContext, {
|
|
265
195
|
items: (flatTree === null || flatTree === void 0 ? void 0 : (_flatTree$ = flatTree[0]) === null || _flatTree$ === void 0 ? void 0 : _flatTree$.rowKey) ? flatTree.map(function (i) {
|
|
@@ -38,10 +38,7 @@ var DraggableTable = function DraggableTable(_ref) {
|
|
|
38
38
|
draggable = draggableProps.draggable,
|
|
39
39
|
rowKey = draggableProps.rowKey,
|
|
40
40
|
onDragStartGuard = draggableProps.onDragStartGuard,
|
|
41
|
-
|
|
42
|
-
onDragOverGuard = draggableProps.onDragOverGuard,
|
|
43
|
-
onDragEndGuard = draggableProps.onDragEndGuard,
|
|
44
|
-
onDragCancelGuard = draggableProps.onDragCancelGuard;
|
|
41
|
+
onDragEndGuard = draggableProps.onDragEndGuard;
|
|
45
42
|
return (0, _jsxRuntime.jsx)(_DndWrapper.default, {
|
|
46
43
|
value: dataSource !== null && dataSource !== void 0 ? dataSource : [],
|
|
47
44
|
onChange: onChange,
|
|
@@ -49,10 +46,7 @@ var DraggableTable = function DraggableTable(_ref) {
|
|
|
49
46
|
draggable: draggable,
|
|
50
47
|
rowKey: rowKey,
|
|
51
48
|
onDragStartGuard: onDragStartGuard,
|
|
52
|
-
onDragMoveGuard: onDragMoveGuard,
|
|
53
|
-
onDragOverGuard: onDragOverGuard,
|
|
54
49
|
onDragEndGuard: onDragEndGuard,
|
|
55
|
-
onDragCancelGuard: onDragCancelGuard,
|
|
56
50
|
children: (0, _jsxRuntime.jsx)(_antd.Table, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
57
51
|
className: "pro-edit-table-drag",
|
|
58
52
|
components: {
|
package/lib/ProTable/index.js
CHANGED
|
@@ -27,7 +27,7 @@ var _reset = _interopRequireDefault(require("../assets/reset.svg"));
|
|
|
27
27
|
var _customColumn = _interopRequireDefault(require("../assets/customColumn.svg"));
|
|
28
28
|
var _utils = require("./utils");
|
|
29
29
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
30
|
-
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "originalDataSource", "onDragStart", "
|
|
30
|
+
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "originalDataSource", "onDragStart", "onDragEnd"],
|
|
31
31
|
_excluded2 = ["resizeColumn", "columnConfig", "cacheTime", "storage"];
|
|
32
32
|
var defaultCacheTime = 1; // columns 配置保存时间为一天
|
|
33
33
|
// 全局上下文
|
|
@@ -61,10 +61,7 @@ function ProTable(props) {
|
|
|
61
61
|
emptyText = _props$emptyText === void 0 ? _locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTable = _locale.default.ProTable) === null || _locale$ProTable === void 0 ? void 0 : _locale$ProTable.noData : _props$emptyText,
|
|
62
62
|
originalDataSource = props.originalDataSource,
|
|
63
63
|
onDragStartGuard = props.onDragStart,
|
|
64
|
-
onDragMoveGuard = props.onDragMove,
|
|
65
|
-
onDragOverGuard = props.onDragOver,
|
|
66
64
|
onDragEndGuard = props.onDragEnd,
|
|
67
|
-
onDragCancelGuard = props.onDragCancel,
|
|
68
65
|
restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
69
66
|
var quickTableConfig = quickConfig ? (0, _objectSpread4.default)({
|
|
70
67
|
columnConfig: true,
|
|
@@ -366,10 +363,7 @@ function ProTable(props) {
|
|
|
366
363
|
draggable: draggable,
|
|
367
364
|
rowKey: rowKey,
|
|
368
365
|
onDragStartGuard: onDragStartGuard,
|
|
369
|
-
|
|
370
|
-
onDragOverGuard: onDragOverGuard,
|
|
371
|
-
onDragEndGuard: onDragEndGuard,
|
|
372
|
-
onDragCancelGuard: onDragCancelGuard
|
|
366
|
+
onDragEndGuard: onDragEndGuard
|
|
373
367
|
},
|
|
374
368
|
tableProps: {
|
|
375
369
|
value: _dataSource,
|