@zat-design/sisyphus-react 3.6.9-beta.7 → 3.6.10-beta.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/coverage/lcov-report/src/.umi/core/devScripts.ts.html +241 -0
- package/coverage/lcov-report/src/.umi/core/history.ts.html +148 -0
- package/coverage/lcov-report/src/.umi/core/index.html +206 -0
- package/coverage/lcov-report/src/.umi/core/plugin.ts.html +109 -0
- package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +160 -0
- package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +97 -0
- package/coverage/lcov-report/src/.umi/core/routes.ts.html +26050 -0
- package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +112 -0
- package/coverage/lcov-report/src/.umi/dumi/demos/index.html +116 -0
- package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +6340 -0
- package/coverage/lcov-report/src/.umi/dumi/index.html +116 -0
- package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +109 -0
- package/coverage/lcov-report/src/.umi/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-antd/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +172 -0
- package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +94 -0
- package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +196 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +106 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +146 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +88 -0
- package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +124 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +1246 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/index.html +161 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +268 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +778 -0
- package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +115 -0
- package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +202 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +97 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +142 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +334 -0
- package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +146 -0
- package/coverage/lcov-report/src/.umi/plugin-model/index.html +146 -0
- package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +121 -0
- package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +298 -0
- package/coverage/lcov-report/src/.umi/plugin-request/index.html +116 -0
- package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +919 -0
- package/coverage/lcov-report/src/.umi/umi.ts.html +268 -0
- package/dist/index.esm.css +41 -41
- package/dist/less.esm.css +41 -41
- package/es/ProEditTable/components/RenderField/index.js +46 -27
- package/es/ProForm/components/combination/ProCascader/index.js +14 -8
- package/es/ProForm/components/render/Render.js +37 -17
- package/es/ProForm/style/index.less +52 -52
- package/es/ProForm/utils/diffOriginal.d.ts +1 -0
- package/es/ProForm/utils/diffOriginal.js +27 -4
- package/es/ProForm/utils/useChanged.js +2 -1
- package/es/ProForm/utils/useListChanged.js +3 -3
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +6 -1
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +176 -40
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +20 -1
- package/es/ProTable/index.js +12 -2
- package/es/ProTable/propsType.d.ts +25 -0
- package/es/ProThemeTools/component/{ProTools → PrdTools}/index.d.ts +2 -2
- package/es/ProThemeTools/component/{ProTools → PrdTools}/index.js +2 -2
- package/es/ProThemeTools/component/index.d.ts +2 -1
- package/es/ProThemeTools/component/index.js +2 -1
- package/es/ProThemeTools/index.js +2 -2
- package/es/ProThemeTools/style/index.less +1 -1
- package/es/ProTreeModal/components/List.js +30 -4
- package/lib/ProEditTable/components/RenderField/index.js +41 -26
- package/lib/ProForm/components/combination/ProCascader/index.js +12 -6
- package/lib/ProForm/components/render/Render.js +35 -17
- package/lib/ProForm/style/index.less +52 -52
- package/lib/ProForm/utils/diffOriginal.d.ts +1 -0
- package/lib/ProForm/utils/diffOriginal.js +27 -3
- package/lib/ProForm/utils/useChanged.js +2 -1
- package/lib/ProForm/utils/useListChanged.js +2 -2
- package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +6 -1
- package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +176 -40
- package/lib/ProTable/components/RcTable/components/DraggableTable/index.js +19 -1
- package/lib/ProTable/index.js +12 -2
- package/lib/ProTable/propsType.d.ts +25 -0
- package/lib/ProThemeTools/component/{ProTools → PrdTools}/index.d.ts +2 -2
- package/lib/ProThemeTools/component/{ProTools → PrdTools}/index.js +2 -2
- package/lib/ProThemeTools/component/index.d.ts +2 -1
- package/lib/ProThemeTools/component/index.js +3 -3
- package/lib/ProThemeTools/index.js +1 -1
- package/lib/ProThemeTools/style/index.less +1 -1
- package/lib/ProTreeModal/components/List.js +30 -4
- package/package.json +1 -1
- package/es/ProEditTable/components/RenderField/ListChanged.d.ts +0 -16
- package/es/ProEditTable/components/RenderField/ListChanged.js +0 -124
- package/es/ProForm/components/render/Changed.d.ts +0 -14
- package/es/ProForm/components/render/Changed.js +0 -64
- package/lib/ProEditTable/components/RenderField/ListChanged.d.ts +0 -16
- package/lib/ProEditTable/components/RenderField/ListChanged.js +0 -129
- package/lib/ProForm/components/render/Changed.d.ts +0 -14
- package/lib/ProForm/components/render/Changed.js +0 -69
- /package/es/ProThemeTools/component/{ProTools → PrdTools}/style/index.less +0 -0
- /package/lib/ProThemeTools/component/{ProTools → PrdTools}/style/index.less +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "antd/es/col/style";
|
|
2
2
|
import _Col from "antd/es/col";
|
|
3
|
+
import "antd/es/tooltip/style";
|
|
4
|
+
import _Tooltip from "antd/es/tooltip";
|
|
3
5
|
import "antd/es/space/style";
|
|
4
6
|
import _Space from "antd/es/space";
|
|
5
7
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
@@ -11,6 +13,7 @@ import "antd/es/form/style";
|
|
|
11
13
|
import _Form from "antd/es/form";
|
|
12
14
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
13
15
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
16
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
14
17
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
15
18
|
var _excluded = ["labelWidth", "hiddenNames", "trim", "upperCase", "className", "rules", "required", "labelRequired", "tooltip"];
|
|
16
19
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -25,10 +28,10 @@ import { isTrim, isUpperCase, findOptionByValue, parseNamePath } from '../../uti
|
|
|
25
28
|
import { useProConfig } from '../../../ProConfigProvider';
|
|
26
29
|
import transformNames from '../../utils/transformNames';
|
|
27
30
|
import valueTypeMap from '../../utils/valueType';
|
|
31
|
+
import { useChanged } from '../../utils/useChanged';
|
|
28
32
|
import tipSvg from '../../../assets/tip.svg';
|
|
29
33
|
import useRules from '../../utils/useRules';
|
|
30
34
|
import ConfirmWrapper from './ConfirmWrapper';
|
|
31
|
-
import Changed from './Changed';
|
|
32
35
|
// 这个组件只管渲染, 参数的整理在外部处理
|
|
33
36
|
var Render = function Render(props) {
|
|
34
37
|
var _ref2, _ref3, _ref4, _ref5, _otherProps$names2;
|
|
@@ -98,6 +101,18 @@ var Render = function Render(props) {
|
|
|
98
101
|
return Array.isArray(name) ? name.join('_') : name;
|
|
99
102
|
}).join('-');
|
|
100
103
|
}, [otherProps === null || otherProps === void 0 ? void 0 : otherProps.names]);
|
|
104
|
+
// 判断当前字段是否变更
|
|
105
|
+
var _useChanged = useChanged({
|
|
106
|
+
name: formItemProps.name,
|
|
107
|
+
names: otherProps.names,
|
|
108
|
+
namesStr: namesStr,
|
|
109
|
+
originalValues: originalValues,
|
|
110
|
+
form: form,
|
|
111
|
+
equalWith: equalWith
|
|
112
|
+
}),
|
|
113
|
+
_useChanged2 = _slicedToArray(_useChanged, 2),
|
|
114
|
+
changed = _useChanged2[0],
|
|
115
|
+
originalValue = _useChanged2[1];
|
|
101
116
|
var internalRule = useRules({
|
|
102
117
|
names: otherProps.names,
|
|
103
118
|
label: otherFormItemProps.label,
|
|
@@ -169,7 +184,7 @@ var Render = function Render(props) {
|
|
|
169
184
|
var lastComponentProps = _objectSpread(_objectSpread(_objectSpread({}, componentProps), _fieldProps), {}, {
|
|
170
185
|
disabled: lastDisabled
|
|
171
186
|
});
|
|
172
|
-
var _className = classNames(_defineProperty(_defineProperty({}, className, className), 'pro-form-item-width-auto', ['Switch'].includes(type)));
|
|
187
|
+
var _className = classNames(_defineProperty(_defineProperty(_defineProperty({}, className, className), 'pro-form-item-changed', changed), 'pro-form-item-width-auto', ['Switch'].includes(type)));
|
|
173
188
|
if (formItemProps.hidden === true || _show === false) {
|
|
174
189
|
// 为了监听shouldUpdate 必须存在一个FormItem, 空Input解决 【[antd: Form.Item] `name` is only used for validate React element】
|
|
175
190
|
return _jsx(_Form.Item, {
|
|
@@ -427,20 +442,6 @@ var Render = function Render(props) {
|
|
|
427
442
|
span: 24 // 默认占一行
|
|
428
443
|
});
|
|
429
444
|
}
|
|
430
|
-
if (originalValues) {
|
|
431
|
-
child = _jsx(Changed, {
|
|
432
|
-
name: formItemProps.name,
|
|
433
|
-
names: otherProps.names,
|
|
434
|
-
namesStr: namesStr,
|
|
435
|
-
originalValues: originalValues,
|
|
436
|
-
form: form,
|
|
437
|
-
equalWith: equalWith,
|
|
438
|
-
originalDiffTip: originalDiffTip,
|
|
439
|
-
type: type,
|
|
440
|
-
onChange: handleChange,
|
|
441
|
-
children: child
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
445
|
var orgFormItem = _jsx(_Form.Item, _objectSpread(_objectSpread({}, omit(_otherFormItemProps, filterFormItemKey)), {}, {
|
|
445
446
|
// @ts-ignore
|
|
446
447
|
_internalItemRender: internalItemRender,
|
|
@@ -467,7 +468,26 @@ var Render = function Render(props) {
|
|
|
467
468
|
})
|
|
468
469
|
});
|
|
469
470
|
}
|
|
470
|
-
|
|
471
|
+
// 不渲染tooltip
|
|
472
|
+
if (!originalDiffTip || ['FormList', 'ProEditTable'].includes(type)) {
|
|
473
|
+
return formItem;
|
|
474
|
+
}
|
|
475
|
+
var title = _jsxs(_Space, {
|
|
476
|
+
children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/React.cloneElement(child, _objectSpread(_objectSpread({}, child), {}, {
|
|
477
|
+
isView: true,
|
|
478
|
+
value: originalValue,
|
|
479
|
+
checked: type === 'Switch' ? originalValue : undefined
|
|
480
|
+
}))]
|
|
481
|
+
});
|
|
482
|
+
return _jsx(_Tooltip, {
|
|
483
|
+
title: title,
|
|
484
|
+
open: changed ? undefined : false,
|
|
485
|
+
// open={true}
|
|
486
|
+
getPopupContainer: function getPopupContainer(target) {
|
|
487
|
+
return target.parentElement;
|
|
488
|
+
},
|
|
489
|
+
children: formItem
|
|
490
|
+
});
|
|
471
491
|
};
|
|
472
492
|
var FormItem = _jsxs(_Fragment, {
|
|
473
493
|
children: [renderItem(), (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$names2 = otherProps.names) === null || _otherProps$names2 === void 0 ? void 0 : _otherProps$names2.length) ? otherProps.names.map(function (name) {
|
|
@@ -116,6 +116,58 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// 比较原始值场景下 不同时的样式
|
|
120
|
+
&.pro-form-item-changed {
|
|
121
|
+
span.@{ant-prefix}-input-affix-wrapper,
|
|
122
|
+
.@{ant-prefix}-select .@{ant-prefix}-select-selector,
|
|
123
|
+
.@{ant-prefix}-picker,
|
|
124
|
+
.@{ant-prefix}-input-number {
|
|
125
|
+
background: @zaui-contract-bg !important;
|
|
126
|
+
|
|
127
|
+
input {
|
|
128
|
+
background: transparent;
|
|
129
|
+
}
|
|
130
|
+
.@{ant-prefix}-select-selection-placeholder {
|
|
131
|
+
z-index: 9;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-switch-handle),
|
|
136
|
+
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-checkbox-wrapper-in-form-item) {
|
|
137
|
+
background: @zaui-contract-bg;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 地址组件
|
|
142
|
+
.@{ant-prefix}-form-item-control-input-content {
|
|
143
|
+
// 查看模式
|
|
144
|
+
& > span {
|
|
145
|
+
border-radius: 4px;
|
|
146
|
+
padding: 5px 8px;
|
|
147
|
+
background: @zaui-contract-bg;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
& > .pro-address {
|
|
151
|
+
.@{ant-prefix}-select-selector,
|
|
152
|
+
.@{ant-prefix}-input-affix-wrapper,
|
|
153
|
+
.@{ant-prefix}-input-disabled {
|
|
154
|
+
background: @zaui-contract-bg;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
& > .@{ant-prefix}-input-group {
|
|
158
|
+
.forever-checkbox {
|
|
159
|
+
background: @zaui-contract-bg;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.pro-form-view-container {
|
|
165
|
+
padding: 4px 8px;
|
|
166
|
+
background: @zaui-contract-bg;
|
|
167
|
+
border-radius: 4px;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
119
171
|
.@{ant-prefix}-row {
|
|
120
172
|
width: 100%;
|
|
121
173
|
}
|
|
@@ -321,56 +373,4 @@
|
|
|
321
373
|
}
|
|
322
374
|
}
|
|
323
375
|
}
|
|
324
|
-
|
|
325
|
-
// 比较原始值场景下 不同时的样式
|
|
326
|
-
.pro-form-item-changed {
|
|
327
|
-
span.@{ant-prefix}-input-affix-wrapper,
|
|
328
|
-
.@{ant-prefix}-select .@{ant-prefix}-select-selector,
|
|
329
|
-
.@{ant-prefix}-picker,
|
|
330
|
-
.@{ant-prefix}-input-number {
|
|
331
|
-
background: @zaui-contract-bg !important;
|
|
332
|
-
|
|
333
|
-
input {
|
|
334
|
-
background: transparent !important;
|
|
335
|
-
}
|
|
336
|
-
.@{ant-prefix}-select-selection-placeholder {
|
|
337
|
-
z-index: 9;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-switch-handle),
|
|
342
|
-
.@{ant-prefix}-form-item-control:has(.@{ant-prefix}-checkbox-wrapper-in-form-item) {
|
|
343
|
-
background: @zaui-contract-bg;
|
|
344
|
-
border-radius: 4px;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// 地址组件
|
|
348
|
-
.@{ant-prefix}-form-item-control-input-content {
|
|
349
|
-
// 查看模式
|
|
350
|
-
& > span {
|
|
351
|
-
border-radius: 4px;
|
|
352
|
-
padding: 5px 8px;
|
|
353
|
-
background: @zaui-contract-bg;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
& > .pro-address {
|
|
357
|
-
.@{ant-prefix}-select-selector,
|
|
358
|
-
.@{ant-prefix}-input-affix-wrapper,
|
|
359
|
-
.@{ant-prefix}-input-disabled {
|
|
360
|
-
background: @zaui-contract-bg;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
& > .@{ant-prefix}-input-group {
|
|
364
|
-
.forever-checkbox {
|
|
365
|
-
background: @zaui-contract-bg;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
.pro-form-view-container {
|
|
371
|
-
padding: 4px 8px;
|
|
372
|
-
background: @zaui-contract-bg;
|
|
373
|
-
border-radius: 4px;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
376
|
}
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import { isEqual, isFunction, isString } from 'lodash';
|
|
2
3
|
var nullValue = [null, undefined, '']; // 输入框空值时可能存在的三种值 视为相等
|
|
4
|
+
/** 将解构后的name值,反向转回names,例如 formData {a:1, b:2} names ['a', 'b'] 返回 [1,2] */
|
|
5
|
+
var extractValues = function extractValues(form, pathString) {
|
|
6
|
+
var _pathString;
|
|
7
|
+
var result = [];
|
|
8
|
+
var PrefixesName = isString(pathString) ? [] : pathString.slice(0, -1);
|
|
9
|
+
if (isString(pathString)) {
|
|
10
|
+
pathString.split('-').forEach(function (item) {
|
|
11
|
+
result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
(_pathString = pathString[pathString.length - 1]) === null || _pathString === void 0 ? void 0 : _pathString.split('-').forEach(function (item) {
|
|
16
|
+
result.push(form.getFieldValue([].concat(_toConsumableArray(PrefixesName), [item])));
|
|
17
|
+
});
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
3
20
|
export var diffOriginal = function diffOriginal(params) {
|
|
21
|
+
var _name$join;
|
|
4
22
|
var originalValue = params.originalValue,
|
|
5
|
-
|
|
6
|
-
equalWith = params.equalWith
|
|
23
|
+
_value = params.value,
|
|
24
|
+
equalWith = params.equalWith,
|
|
25
|
+
form = params.form,
|
|
26
|
+
name = params.name;
|
|
27
|
+
var isNames = Array.isArray(name) && ((_name$join = name.join(',')) === null || _name$join === void 0 ? void 0 : _name$join.includes('-')) || (name === null || name === void 0 ? void 0 : name.includes('-'));
|
|
28
|
+
var value = !isNames ? _value : extractValues(form, name);
|
|
7
29
|
// 支持传入自定义比较事件
|
|
8
30
|
if (isFunction(equalWith)) {
|
|
9
31
|
return !equalWith(originalValue, value);
|
|
@@ -18,7 +40,8 @@ export var diffOriginal = function diffOriginal(params) {
|
|
|
18
40
|
});
|
|
19
41
|
}
|
|
20
42
|
if (!nullValue.includes(value) || !nullValue.includes(originalValue)) {
|
|
21
|
-
|
|
43
|
+
var res = !isEqual(value, originalValue);
|
|
44
|
+
return res;
|
|
22
45
|
}
|
|
23
46
|
return false;
|
|
24
47
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "antd/es/form/style";
|
|
2
2
|
import _Form from "antd/es/form";
|
|
3
|
-
import { get } from 'lodash';
|
|
3
|
+
import { get, isString } from 'lodash';
|
|
4
4
|
import { diffOriginal } from './diffOriginal';
|
|
5
5
|
var toNamePath = function toNamePath(name) {
|
|
6
6
|
if (Array.isArray(name)) {
|
|
@@ -86,8 +86,8 @@ export var useListChanged = function useListChanged(params) {
|
|
|
86
86
|
value: value,
|
|
87
87
|
originalValue: originalValue,
|
|
88
88
|
form: form,
|
|
89
|
-
equalWith: equalWith
|
|
90
|
-
|
|
89
|
+
equalWith: equalWith,
|
|
90
|
+
name: isString(namesStr) ? namesStr : originalName || name
|
|
91
91
|
});
|
|
92
92
|
return [changed, originalValue];
|
|
93
93
|
};
|
package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts
CHANGED
|
@@ -5,12 +5,17 @@ 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 }: {
|
|
8
|
+
declare const DndWrapper: ({ draggable, value, onChange, disabled, children, rowKey, onDragStartGuard, onDragMoveGuard, onDragOverGuard, onDragEndGuard, onDragCancelGuard, }: {
|
|
9
9
|
draggable: any;
|
|
10
10
|
value: any;
|
|
11
11
|
onChange: any;
|
|
12
12
|
disabled: any;
|
|
13
13
|
children: any;
|
|
14
14
|
rowKey: any;
|
|
15
|
+
onDragStartGuard: any;
|
|
16
|
+
onDragMoveGuard: any;
|
|
17
|
+
onDragOverGuard: any;
|
|
18
|
+
onDragEndGuard: any;
|
|
19
|
+
onDragCancelGuard: any;
|
|
15
20
|
}) => any;
|
|
16
21
|
export default DndWrapper;
|
package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
1
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
5
|
var _excluded = ["disabled", "children"];
|
|
@@ -6,6 +8,7 @@ import React from 'react';
|
|
|
6
8
|
import { DndContext, closestCorners } from '@dnd-kit/core';
|
|
7
9
|
import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
8
10
|
import { CSS } from '@dnd-kit/utilities';
|
|
11
|
+
import { isFunction } from 'lodash';
|
|
9
12
|
import { addLevelAndParentId, treeNodeFind, transformTreeToArray, createTreeFromArray } from './utils/index';
|
|
10
13
|
import ProIcon from '../../../../../../../ProIcon';
|
|
11
14
|
export var Row = function Row(props) {
|
|
@@ -67,48 +70,177 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
67
70
|
onChange = _ref2.onChange,
|
|
68
71
|
disabled = _ref2.disabled,
|
|
69
72
|
children = _ref2.children,
|
|
70
|
-
rowKey = _ref2.rowKey
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
overParentId = overObject.parentId;
|
|
89
|
-
if (activeLevel === overLevel && activeParentId === overParentId) {
|
|
90
|
-
// 将树平铺
|
|
91
|
-
var _flatTree = transformTreeToArray(transformedValue).map(function (item) {
|
|
92
|
-
return _objectSpread(_objectSpread({}, item), {}, {
|
|
93
|
-
children: undefined
|
|
73
|
+
rowKey = _ref2.rowKey,
|
|
74
|
+
onDragStartGuard = _ref2.onDragStartGuard,
|
|
75
|
+
onDragMoveGuard = _ref2.onDragMoveGuard,
|
|
76
|
+
onDragOverGuard = _ref2.onDragOverGuard,
|
|
77
|
+
onDragEndGuard = _ref2.onDragEndGuard,
|
|
78
|
+
onDragCancelGuard = _ref2.onDragCancelGuard;
|
|
79
|
+
var onDragStart = /*#__PURE__*/function () {
|
|
80
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
|
|
81
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
82
|
+
while (1) switch (_context.prev = _context.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
if (!(onDragStartGuard && isFunction(onDragStartGuard))) {
|
|
85
|
+
_context.next = 3;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
_context.next = 3;
|
|
89
|
+
return onDragStartGuard({
|
|
90
|
+
event: event
|
|
94
91
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return
|
|
98
|
-
});
|
|
99
|
-
var overIndex = _flatTree.findIndex(function (i) {
|
|
100
|
-
return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
|
101
|
-
});
|
|
102
|
-
var nextValue = arrayMove(_flatTree, activeIndex, overIndex);
|
|
103
|
-
onChange(createTreeFromArray(nextValue, {
|
|
104
|
-
itemKey: 'rowKey',
|
|
105
|
-
parentKey: 'parentId',
|
|
106
|
-
childrenKey: 'children'
|
|
107
|
-
}));
|
|
92
|
+
case 3:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context.stop();
|
|
108
95
|
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
96
|
+
}, _callee);
|
|
97
|
+
}));
|
|
98
|
+
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
|
+
return _ref4.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
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
|
+
var onDragEnd = /*#__PURE__*/function () {
|
|
149
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref6) {
|
|
150
|
+
var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
152
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
active = _ref6.active, over = _ref6.over;
|
|
155
|
+
// 为数据源划分层级及parentId
|
|
156
|
+
transformedValue = addLevelAndParentId(value, rowKey); // 同一level层级的且parentId相同的,可以互相之间拖拽替换
|
|
157
|
+
if (!(active.id !== (over === null || over === void 0 ? void 0 : over.id))) {
|
|
158
|
+
_context4.next = 15;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
activeObject = treeNodeFind(transformedValue, function (t) {
|
|
162
|
+
return t.rowKey === active.id;
|
|
163
|
+
});
|
|
164
|
+
overObject = treeNodeFind(transformedValue, function (t) {
|
|
165
|
+
return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
|
166
|
+
});
|
|
167
|
+
if (!(activeObject && overObject)) {
|
|
168
|
+
_context4.next = 15;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
activeLevel = activeObject.level, activeParentId = activeObject.parentId;
|
|
172
|
+
overLevel = overObject.level, overParentId = overObject.parentId; // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
|
|
173
|
+
if (!(onDragEndGuard && isFunction(onDragEndGuard))) {
|
|
174
|
+
_context4.next = 14;
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
_context4.next = 11;
|
|
178
|
+
return onDragEndGuard({
|
|
179
|
+
activeObject: activeObject,
|
|
180
|
+
overObject: overObject,
|
|
181
|
+
currentDataSource: value,
|
|
182
|
+
transformTreeToArray: transformTreeToArray,
|
|
183
|
+
arrayMove: arrayMove,
|
|
184
|
+
createTreeFromArray: createTreeFromArray
|
|
185
|
+
});
|
|
186
|
+
case 11:
|
|
187
|
+
nextDataSource = _context4.sent;
|
|
188
|
+
onChange(nextDataSource !== null && nextDataSource !== void 0 ? nextDataSource : []);
|
|
189
|
+
return _context4.abrupt("return");
|
|
190
|
+
case 14:
|
|
191
|
+
if (activeLevel === overLevel && activeParentId === overParentId) {
|
|
192
|
+
// 将树平铺
|
|
193
|
+
_flatTree = transformTreeToArray(transformedValue).map(function (item) {
|
|
194
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
195
|
+
children: undefined
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
activeIndex = _flatTree.findIndex(function (i) {
|
|
199
|
+
return i.rowKey === active.id;
|
|
200
|
+
});
|
|
201
|
+
overIndex = _flatTree.findIndex(function (i) {
|
|
202
|
+
return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
|
203
|
+
});
|
|
204
|
+
nextValue = arrayMove(_flatTree, activeIndex, overIndex);
|
|
205
|
+
onChange(createTreeFromArray(nextValue, {
|
|
206
|
+
itemKey: 'rowKey',
|
|
207
|
+
parentKey: 'parentId',
|
|
208
|
+
childrenKey: 'children'
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
case 15:
|
|
212
|
+
case "end":
|
|
213
|
+
return _context4.stop();
|
|
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();
|
|
237
|
+
}
|
|
238
|
+
}, _callee5);
|
|
239
|
+
}));
|
|
240
|
+
return function onDragCancel(_x5) {
|
|
241
|
+
return _ref8.apply(this, arguments);
|
|
242
|
+
};
|
|
243
|
+
}();
|
|
112
244
|
// 将树平铺
|
|
113
245
|
var flatTree = transformTreeToArray(value).map(function (item) {
|
|
114
246
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
@@ -117,6 +249,10 @@ var DndWrapper = function DndWrapper(_ref2) {
|
|
|
117
249
|
});
|
|
118
250
|
return draggable && !disabled ? _jsx(DndContext, {
|
|
119
251
|
onDragEnd: onDragEnd,
|
|
252
|
+
onDragStart: onDragStart,
|
|
253
|
+
onDragMove: onDragMove,
|
|
254
|
+
onDragOver: onDragOver,
|
|
255
|
+
onDragCancel: onDragCancel,
|
|
120
256
|
collisionDetection: closestCorners,
|
|
121
257
|
children: _jsx(SortableContext, {
|
|
122
258
|
items: (flatTree === null || flatTree === void 0 ? void 0 : (_flatTree$ = flatTree[0]) === null || _flatTree$ === void 0 ? void 0 : _flatTree$.rowKey) ? flatTree.map(function (i) {
|
|
@@ -4,6 +4,15 @@ import _Table from "antd/es/table";
|
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["dataSource", "tableProps", "draggableProps", "summaryProps", "emptyTextProps"];
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/*
|
|
8
|
+
* @Author: za-xuwenli xuwenli@zhongan.io
|
|
9
|
+
* @Date: 2024-08-09 13:48:59
|
|
10
|
+
* @LastEditors: za-xuwenli xuwenli@zhongan.io
|
|
11
|
+
* @LastEditTime: 2024-08-20 19:31:24
|
|
12
|
+
* @FilePath: /za-material-warehouse/src/ProTable/components/RcTable/components/DraggableTable/index.tsx
|
|
13
|
+
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
14
|
+
*/
|
|
15
|
+
|
|
7
16
|
import { memo } from 'react';
|
|
8
17
|
import DndWrapper, { Row } from './components/DndWrapper';
|
|
9
18
|
import { RenderEmptyText, RenderSummary } from '../../../index';
|
|
@@ -21,13 +30,23 @@ var DraggableTable = function DraggableTable(_ref) {
|
|
|
21
30
|
disabled = tableProps.disabled;
|
|
22
31
|
var onChange = draggableProps.onChange,
|
|
23
32
|
draggable = draggableProps.draggable,
|
|
24
|
-
rowKey = draggableProps.rowKey
|
|
33
|
+
rowKey = draggableProps.rowKey,
|
|
34
|
+
onDragStartGuard = draggableProps.onDragStartGuard,
|
|
35
|
+
onDragMoveGuard = draggableProps.onDragMoveGuard,
|
|
36
|
+
onDragOverGuard = draggableProps.onDragOverGuard,
|
|
37
|
+
onDragEndGuard = draggableProps.onDragEndGuard,
|
|
38
|
+
onDragCancelGuard = draggableProps.onDragCancelGuard;
|
|
25
39
|
return _jsx(DndWrapper, {
|
|
26
40
|
value: dataSource !== null && dataSource !== void 0 ? dataSource : [],
|
|
27
41
|
onChange: onChange,
|
|
28
42
|
disabled: disabled,
|
|
29
43
|
draggable: draggable,
|
|
30
44
|
rowKey: rowKey,
|
|
45
|
+
onDragStartGuard: onDragStartGuard,
|
|
46
|
+
onDragMoveGuard: onDragMoveGuard,
|
|
47
|
+
onDragOverGuard: onDragOverGuard,
|
|
48
|
+
onDragEndGuard: onDragEndGuard,
|
|
49
|
+
onDragCancelGuard: onDragCancelGuard,
|
|
31
50
|
children: _jsx(_Table, _objectSpread(_objectSpread({
|
|
32
51
|
className: "pro-edit-table-drag",
|
|
33
52
|
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"],
|
|
8
|
+
var _excluded = ["tableId", "headerRender", "footerRender", "quickConfig", "stripe", "columns", "className", "draggable", "disabled", "isView", "rowDisabled", "summary", "emptyText", "originalDataSource", "onDragStart", "onDragMove", "onDragOver", "onDragEnd", "onDragCancel"],
|
|
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';
|
|
@@ -53,6 +53,11 @@ function ProTable(props) {
|
|
|
53
53
|
_props$emptyText = props.emptyText,
|
|
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
|
+
onDragStartGuard = props.onDragStart,
|
|
57
|
+
onDragMoveGuard = props.onDragMove,
|
|
58
|
+
onDragOverGuard = props.onDragOver,
|
|
59
|
+
onDragEndGuard = props.onDragEnd,
|
|
60
|
+
onDragCancelGuard = props.onDragCancel,
|
|
56
61
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
57
62
|
var quickTableConfig = quickConfig ? _objectSpread({
|
|
58
63
|
columnConfig: true,
|
|
@@ -352,7 +357,12 @@ function ProTable(props) {
|
|
|
352
357
|
draggableProps: {
|
|
353
358
|
onChange: onDataSourceChange,
|
|
354
359
|
draggable: draggable,
|
|
355
|
-
rowKey: rowKey
|
|
360
|
+
rowKey: rowKey,
|
|
361
|
+
onDragStartGuard: onDragStartGuard,
|
|
362
|
+
onDragMoveGuard: onDragMoveGuard,
|
|
363
|
+
onDragOverGuard: onDragOverGuard,
|
|
364
|
+
onDragEndGuard: onDragEndGuard,
|
|
365
|
+
onDragCancelGuard: onDragCancelGuard
|
|
356
366
|
},
|
|
357
367
|
tableProps: {
|
|
358
368
|
value: _dataSource,
|