@zat-design/sisyphus-react 3.6.9-beta.7 → 3.6.10-beta.2

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.
Files changed (92) hide show
  1. package/coverage/lcov-report/src/.umi/core/devScripts.ts.html +241 -0
  2. package/coverage/lcov-report/src/.umi/core/history.ts.html +148 -0
  3. package/coverage/lcov-report/src/.umi/core/index.html +206 -0
  4. package/coverage/lcov-report/src/.umi/core/plugin.ts.html +109 -0
  5. package/coverage/lcov-report/src/.umi/core/pluginRegister.ts.html +160 -0
  6. package/coverage/lcov-report/src/.umi/core/polyfill.ts.html +97 -0
  7. package/coverage/lcov-report/src/.umi/core/routes.ts.html +26050 -0
  8. package/coverage/lcov-report/src/.umi/core/umiExports.ts.html +112 -0
  9. package/coverage/lcov-report/src/.umi/dumi/demos/index.html +116 -0
  10. package/coverage/lcov-report/src/.umi/dumi/demos/index.ts.html +6340 -0
  11. package/coverage/lcov-report/src/.umi/dumi/index.html +116 -0
  12. package/coverage/lcov-report/src/.umi/dumi/layout.tsx.html +109 -0
  13. package/coverage/lcov-report/src/.umi/index.html +116 -0
  14. package/coverage/lcov-report/src/.umi/plugin-antd/index.html +116 -0
  15. package/coverage/lcov-report/src/.umi/plugin-antd/runtime.tsx.html +172 -0
  16. package/coverage/lcov-report/src/.umi/plugin-helmet/exports.ts.html +94 -0
  17. package/coverage/lcov-report/src/.umi/plugin-helmet/index.html +116 -0
  18. package/coverage/lcov-report/src/.umi/plugin-initial-state/Provider.tsx.html +196 -0
  19. package/coverage/lcov-report/src/.umi/plugin-initial-state/exports.ts.html +106 -0
  20. package/coverage/lcov-report/src/.umi/plugin-initial-state/index.html +146 -0
  21. package/coverage/lcov-report/src/.umi/plugin-initial-state/models/index.html +116 -0
  22. package/coverage/lcov-report/src/.umi/plugin-initial-state/models/initialState.ts.html +88 -0
  23. package/coverage/lcov-report/src/.umi/plugin-initial-state/runtime.tsx.html +124 -0
  24. package/coverage/lcov-report/src/.umi/plugin-locale/SelectLang.tsx.html +1246 -0
  25. package/coverage/lcov-report/src/.umi/plugin-locale/index.html +161 -0
  26. package/coverage/lcov-report/src/.umi/plugin-locale/locale.tsx.html +268 -0
  27. package/coverage/lcov-report/src/.umi/plugin-locale/localeExports.ts.html +778 -0
  28. package/coverage/lcov-report/src/.umi/plugin-locale/runtime.tsx.html +115 -0
  29. package/coverage/lcov-report/src/.umi/plugin-model/Provider.tsx.html +202 -0
  30. package/coverage/lcov-report/src/.umi/plugin-model/helpers/constant.tsx.html +97 -0
  31. package/coverage/lcov-report/src/.umi/plugin-model/helpers/dispatcher.tsx.html +142 -0
  32. package/coverage/lcov-report/src/.umi/plugin-model/helpers/executor.tsx.html +334 -0
  33. package/coverage/lcov-report/src/.umi/plugin-model/helpers/index.html +146 -0
  34. package/coverage/lcov-report/src/.umi/plugin-model/index.html +146 -0
  35. package/coverage/lcov-report/src/.umi/plugin-model/runtime.tsx.html +121 -0
  36. package/coverage/lcov-report/src/.umi/plugin-model/useModel.tsx.html +298 -0
  37. package/coverage/lcov-report/src/.umi/plugin-request/index.html +116 -0
  38. package/coverage/lcov-report/src/.umi/plugin-request/request.ts.html +919 -0
  39. package/coverage/lcov-report/src/.umi/umi.ts.html +268 -0
  40. package/dist/index.esm.css +41 -41
  41. package/dist/less.esm.css +41 -41
  42. package/es/ProEditTable/components/RenderField/index.js +46 -27
  43. package/es/ProForm/components/combination/ProCascader/index.js +14 -8
  44. package/es/ProForm/components/render/Render.js +37 -17
  45. package/es/ProForm/style/index.less +52 -52
  46. package/es/ProForm/utils/diffOriginal.d.ts +1 -0
  47. package/es/ProForm/utils/diffOriginal.js +27 -4
  48. package/es/ProForm/utils/useChanged.js +2 -1
  49. package/es/ProForm/utils/useListChanged.js +3 -3
  50. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +3 -1
  51. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +106 -40
  52. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +14 -1
  53. package/es/ProTable/index.js +6 -2
  54. package/es/ProTable/propsType.d.ts +22 -0
  55. package/es/ProThemeTools/component/{ProTools → PrdTools}/index.d.ts +2 -2
  56. package/es/ProThemeTools/component/{ProTools → PrdTools}/index.js +2 -2
  57. package/es/ProThemeTools/component/index.d.ts +2 -1
  58. package/es/ProThemeTools/component/index.js +2 -1
  59. package/es/ProThemeTools/index.js +2 -2
  60. package/es/ProThemeTools/style/index.less +1 -1
  61. package/es/ProTreeModal/components/List.js +30 -4
  62. package/lib/ProEditTable/components/RenderField/index.js +41 -26
  63. package/lib/ProForm/components/combination/ProCascader/index.js +12 -6
  64. package/lib/ProForm/components/render/Render.js +35 -17
  65. package/lib/ProForm/style/index.less +52 -52
  66. package/lib/ProForm/utils/diffOriginal.d.ts +1 -0
  67. package/lib/ProForm/utils/diffOriginal.js +27 -3
  68. package/lib/ProForm/utils/useChanged.js +2 -1
  69. package/lib/ProForm/utils/useListChanged.js +2 -2
  70. package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +3 -1
  71. package/lib/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +106 -40
  72. package/lib/ProTable/components/RcTable/components/DraggableTable/index.js +13 -1
  73. package/lib/ProTable/index.js +6 -2
  74. package/lib/ProTable/propsType.d.ts +22 -0
  75. package/lib/ProThemeTools/component/{ProTools → PrdTools}/index.d.ts +2 -2
  76. package/lib/ProThemeTools/component/{ProTools → PrdTools}/index.js +2 -2
  77. package/lib/ProThemeTools/component/index.d.ts +2 -1
  78. package/lib/ProThemeTools/component/index.js +3 -3
  79. package/lib/ProThemeTools/index.js +1 -1
  80. package/lib/ProThemeTools/style/index.less +1 -1
  81. package/lib/ProTreeModal/components/List.js +30 -4
  82. package/package.json +1 -1
  83. package/es/ProEditTable/components/RenderField/ListChanged.d.ts +0 -16
  84. package/es/ProEditTable/components/RenderField/ListChanged.js +0 -124
  85. package/es/ProForm/components/render/Changed.d.ts +0 -14
  86. package/es/ProForm/components/render/Changed.js +0 -64
  87. package/lib/ProEditTable/components/RenderField/ListChanged.d.ts +0 -16
  88. package/lib/ProEditTable/components/RenderField/ListChanged.js +0 -129
  89. package/lib/ProForm/components/render/Changed.d.ts +0 -14
  90. package/lib/ProForm/components/render/Changed.js +0 -69
  91. /package/es/ProThemeTools/component/{ProTools → PrdTools}/style/index.less +0 -0
  92. /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
- return formItem;
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
  }
@@ -3,6 +3,7 @@ interface Params {
3
3
  originalValue: any;
4
4
  value: any;
5
5
  form: FormInstance;
6
+ name?: string | any[];
6
7
  equalWith?: (originalValue: any, currentValue: any) => boolean;
7
8
  }
8
9
  export declare const diffOriginal: (params: Params) => boolean;
@@ -1,9 +1,31 @@
1
- import { isEqual, isFunction } from 'lodash';
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
- value = params.value,
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
- return !isEqual(value, originalValue);
43
+ var res = !isEqual(value, originalValue);
44
+ return res;
22
45
  }
23
46
  return false;
24
47
  };
@@ -19,7 +19,8 @@ export var useChanged = function useChanged(_ref) {
19
19
  originalValue: originalValue,
20
20
  value: value,
21
21
  form: form,
22
- equalWith: equalWith
22
+ equalWith: equalWith,
23
+ name: namesStr || name
23
24
  });
24
25
  return [changed, originalValue];
25
26
  };
@@ -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
- // name: isString(namesStr) ? namesStr : originalName || name,
89
+ equalWith: equalWith,
90
+ name: isString(namesStr) ? namesStr : originalName || name
91
91
  });
92
92
  return [changed, originalValue];
93
93
  };
@@ -5,12 +5,14 @@ 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, onDragEndGuard, }: {
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
+ onDragEndGuard: any;
15
17
  }) => any;
16
18
  export default DndWrapper;
@@ -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,110 @@ 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
- var onDragEnd = function onDragEnd(_ref3) {
72
- var active = _ref3.active,
73
- over = _ref3.over;
74
- // 为数据源划分层级及parentId
75
- var transformedValue = addLevelAndParentId(value, rowKey);
76
- // 同一level层级的且parentId相同的,可以互相之间拖拽替换
77
- if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
78
- var activeObject = treeNodeFind(transformedValue, function (t) {
79
- return t.rowKey === active.id;
80
- });
81
- var overObject = treeNodeFind(transformedValue, function (t) {
82
- return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
83
- });
84
- if (activeObject && overObject) {
85
- var activeLevel = activeObject.level,
86
- activeParentId = activeObject.parentId;
87
- var overLevel = overObject.level,
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
+ onDragEndGuard = _ref2.onDragEndGuard;
76
+ var onDragStart = /*#__PURE__*/function () {
77
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
78
+ var active, transformedValue, activeObject;
79
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
80
+ while (1) switch (_context.prev = _context.next) {
81
+ case 0:
82
+ active = _ref3.active;
83
+ if (!(onDragStartGuard && isFunction(onDragStartGuard))) {
84
+ _context.next = 6;
85
+ break;
86
+ }
87
+ // 为数据源划分层级及parentId
88
+ transformedValue = addLevelAndParentId(value, rowKey);
89
+ activeObject = treeNodeFind(transformedValue, function (t) {
90
+ return t.rowKey === active.id;
94
91
  });
95
- });
96
- var activeIndex = _flatTree.findIndex(function (i) {
97
- return i.rowKey === active.id;
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
+ _context.next = 6;
93
+ return onDragStartGuard({
94
+ activeObject: activeObject,
95
+ currentDataSource: value
96
+ });
97
+ case 6:
98
+ case "end":
99
+ return _context.stop();
108
100
  }
109
- }
110
- }
111
- };
101
+ }, _callee);
102
+ }));
103
+ return function onDragStart(_x) {
104
+ return _ref4.apply(this, arguments);
105
+ };
106
+ }();
107
+ var onDragEnd = /*#__PURE__*/function () {
108
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
109
+ var active, over, transformedValue, activeObject, overObject, activeLevel, activeParentId, overLevel, overParentId, nextDataSource, _flatTree, activeIndex, overIndex, nextValue;
110
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
111
+ while (1) switch (_context2.prev = _context2.next) {
112
+ case 0:
113
+ active = _ref5.active, over = _ref5.over;
114
+ // 为数据源划分层级及parentId
115
+ transformedValue = addLevelAndParentId(value, rowKey); // 同一level层级的且parentId相同的,可以互相之间拖拽替换
116
+ if (!(active.id !== (over === null || over === void 0 ? void 0 : over.id))) {
117
+ _context2.next = 15;
118
+ break;
119
+ }
120
+ activeObject = treeNodeFind(transformedValue, function (t) {
121
+ return t.rowKey === active.id;
122
+ });
123
+ overObject = treeNodeFind(transformedValue, function (t) {
124
+ return t.rowKey === (over === null || over === void 0 ? void 0 : over.id);
125
+ });
126
+ if (!(activeObject && overObject)) {
127
+ _context2.next = 15;
128
+ break;
129
+ }
130
+ activeLevel = activeObject.level, activeParentId = activeObject.parentId;
131
+ overLevel = overObject.level, overParentId = overObject.parentId; // 如果传了onDragEndGuard 则视为外部业务逻辑自处理
132
+ if (!(onDragEndGuard && isFunction(onDragEndGuard))) {
133
+ _context2.next = 14;
134
+ break;
135
+ }
136
+ _context2.next = 11;
137
+ return onDragEndGuard({
138
+ activeObject: activeObject,
139
+ overObject: overObject,
140
+ currentDataSource: value
141
+ });
142
+ case 11:
143
+ nextDataSource = _context2.sent;
144
+ onChange(nextDataSource !== null && nextDataSource !== void 0 ? nextDataSource : []);
145
+ return _context2.abrupt("return");
146
+ case 14:
147
+ if (activeLevel === overLevel && activeParentId === overParentId) {
148
+ // 将树平铺
149
+ _flatTree = transformTreeToArray(transformedValue).map(function (item) {
150
+ return _objectSpread(_objectSpread({}, item), {}, {
151
+ children: undefined
152
+ });
153
+ });
154
+ activeIndex = _flatTree.findIndex(function (i) {
155
+ return i.rowKey === active.id;
156
+ });
157
+ overIndex = _flatTree.findIndex(function (i) {
158
+ return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
159
+ });
160
+ nextValue = arrayMove(_flatTree, activeIndex, overIndex);
161
+ onChange(createTreeFromArray(nextValue, {
162
+ itemKey: 'rowKey',
163
+ parentKey: 'parentId',
164
+ childrenKey: 'children'
165
+ }));
166
+ }
167
+ case 15:
168
+ case "end":
169
+ return _context2.stop();
170
+ }
171
+ }, _callee2);
172
+ }));
173
+ return function onDragEnd(_x2) {
174
+ return _ref6.apply(this, arguments);
175
+ };
176
+ }();
112
177
  // 将树平铺
113
178
  var flatTree = transformTreeToArray(value).map(function (item) {
114
179
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -116,6 +181,7 @@ var DndWrapper = function DndWrapper(_ref2) {
116
181
  });
117
182
  });
118
183
  return draggable && !disabled ? _jsx(DndContext, {
184
+ onDragStart: onDragStart,
119
185
  onDragEnd: onDragEnd,
120
186
  collisionDetection: closestCorners,
121
187
  children: _jsx(SortableContext, {
@@ -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,17 @@ 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
+ onDragEndGuard = draggableProps.onDragEndGuard;
25
36
  return _jsx(DndWrapper, {
26
37
  value: dataSource !== null && dataSource !== void 0 ? dataSource : [],
27
38
  onChange: onChange,
28
39
  disabled: disabled,
29
40
  draggable: draggable,
30
41
  rowKey: rowKey,
42
+ onDragStartGuard: onDragStartGuard,
43
+ onDragEndGuard: onDragEndGuard,
31
44
  children: _jsx(_Table, _objectSpread(_objectSpread({
32
45
  className: "pro-edit-table-drag",
33
46
  components: {
@@ -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", "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';
@@ -53,6 +53,8 @@ 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
+ onDragEndGuard = props.onDragEnd,
56
58
  restProps = _objectWithoutProperties(props, _excluded);
57
59
  var quickTableConfig = quickConfig ? _objectSpread({
58
60
  columnConfig: true,
@@ -352,7 +354,9 @@ function ProTable(props) {
352
354
  draggableProps: {
353
355
  onChange: onDataSourceChange,
354
356
  draggable: draggable,
355
- rowKey: rowKey
357
+ rowKey: rowKey,
358
+ onDragStartGuard: onDragStartGuard,
359
+ onDragEndGuard: onDragEndGuard
356
360
  },
357
361
  tableProps: {
358
362
  value: _dataSource,
@@ -41,6 +41,23 @@ export interface ProTableColumn extends Omit<ColumnType<any>, 'dataIndex'> {
41
41
  toolTipProps?: TooltipProps & React.RefAttributes<unknown>;
42
42
  transform?: (value: any, record?: any) => string[];
43
43
  }
44
+ export interface CreateTreeFromArrayOptions {
45
+ itemKey?: string;
46
+ parentKey?: string;
47
+ childrenKey?: string;
48
+ }
49
+ export interface DragCommonGuardProps<T> {
50
+ event: T;
51
+ }
52
+ export interface DragEndGuardProps {
53
+ activeObject: any;
54
+ overObject?: any;
55
+ currentDataSource: any[];
56
+ }
57
+ export interface DragStartGuardProps {
58
+ activeObject: any;
59
+ currentDataSource: any[];
60
+ }
44
61
  export interface ProTableProps<T = any> extends Omit<TableProps<any>, 'summary' | 'columns'> {
45
62
  tableId?: string;
46
63
  rowKey?: string | GetRowKey<any>;
@@ -67,6 +84,11 @@ export interface ProTableProps<T = any> extends Omit<TableProps<any>, 'summary'
67
84
  stripe?: boolean;
68
85
  columns: ProTableColumn[];
69
86
  originalDataSource?: any[];
87
+ /**
88
+ * 拖拽额外配置
89
+ */
90
+ onDragStart?: DragStartGuardProps;
91
+ onDragEnd?: DragEndGuardProps;
70
92
  }
71
93
  export type ProTableValueType = 'percentage' | 'permillage' | 'thousandth' | 'datePicker' | 'enumName' | 'enumCodeName' | 'address' | 'thousandthCNY' | 'date' | 'dateTime' | 'dateStartTime' | 'dateEndTime' | 'dateStartEndTime';
72
94
  export interface Response<T = any> {
@@ -1,3 +1,3 @@
1
1
  import type { DevToolsPropsType } from '../../propsType';
2
- declare const ProTools: ({ onReset, onClose, setState, open, state, tableBorder, tableStripe, }: DevToolsPropsType) => import("react/jsx-runtime").JSX.Element;
3
- export default ProTools;
2
+ declare const PrdTools: ({ onReset, onClose, setState, open, state, tableBorder, tableStripe, }: DevToolsPropsType) => import("react/jsx-runtime").JSX.Element;
3
+ export default PrdTools;
@@ -21,7 +21,7 @@ var connect = function connect(Component) {
21
21
  return ComponentWrapper;
22
22
  };
23
23
  var NewDrawer = connect(_Drawer);
24
- var ProTools = function ProTools(_ref) {
24
+ var PrdTools = function PrdTools(_ref) {
25
25
  var onReset = _ref.onReset,
26
26
  onClose = _ref.onClose,
27
27
  setState = _ref.setState,
@@ -266,4 +266,4 @@ var ProTools = function ProTools(_ref) {
266
266
  })]
267
267
  });
268
268
  };
269
- export default ProTools;
269
+ export default PrdTools;
@@ -1 +1,2 @@
1
- export { default as ProTools } from './ProTools';
1
+ /// <reference types="typings" />
2
+ export { default as PrdTools } from './PrdTools';
@@ -1 +1,2 @@
1
- export { default as ProTools } from './ProTools';
1
+ /// <reference path="../../../typings.d.ts" />;
2
+ export { default as PrdTools } from './PrdTools';
@@ -17,7 +17,7 @@ import { isEqual } from 'lodash';
17
17
  import classnames from 'classnames';
18
18
  import { getKebabCase, setThemes, setTableBorder, getMapKebabCase, getMapHumpCase } from './utils/index';
19
19
  import settingSvg from '../assets/setting.svg';
20
- import { ProTools } from './component';
20
+ import { PrdTools } from './component';
21
21
  import locale from '../locale';
22
22
  var defaultCacheTime = 1; // 配置保存时间为一天
23
23
  var defaultThemeConfig = {
@@ -183,7 +183,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
183
183
  className: "setting-icon",
184
184
  src: settingSvg
185
185
  })
186
- }), _jsx(ProTools, {
186
+ }), _jsx(PrdTools, {
187
187
  prefixCls: prefixCls,
188
188
  onReset: onReset,
189
189
  onClose: toggle,
@@ -1,7 +1,7 @@
1
1
  @root-entry-name: 'default';
2
2
  @import (reference) '~antd/es/style/themes/index.less';
3
3
 
4
- @import '../component/ProTools/style/index.less';
4
+ @import '../component/PrdTools/style/index.less';
5
5
 
6
6
  .pro-theme-tools {
7
7
  display: flex;