@zat-design/sisyphus-react 3.8.3-beta.2 → 3.8.3-beta.21

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 (66) hide show
  1. package/dist/index.esm.css +38 -3
  2. package/dist/less.esm.css +37 -2
  3. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +83 -20
  4. package/es/ProEditTable/components/RenderField/index.js +6 -2
  5. package/es/ProEditTable/index.js +18 -9
  6. package/es/ProEditTable/propsType.d.ts +3 -6
  7. package/es/ProEditTable/style/index.less +0 -1
  8. package/es/ProEditTable/utils/index.js +10 -3
  9. package/es/ProForm/components/base/InputNumber/index.js +1 -1
  10. package/es/ProForm/components/combination/FormList/components/BlockFields.d.ts +2 -0
  11. package/es/ProForm/components/combination/FormList/components/BlockFields.js +4 -2
  12. package/es/ProForm/components/combination/FormList/components/LineFields.d.ts +2 -0
  13. package/es/ProForm/components/combination/FormList/components/LineFields.js +4 -2
  14. package/es/ProForm/components/combination/FormList/index.js +14 -3
  15. package/es/ProForm/components/combination/Group/index.js +3 -4
  16. package/es/ProForm/components/combination/ProCascader/index.js +21 -14
  17. package/es/ProForm/components/combination/ProModalSelect/index.js +17 -3
  18. package/es/ProForm/components/render/ChangedWrapper.js +29 -10
  19. package/es/ProForm/components/render/Render.js +3 -1
  20. package/es/ProForm/components/render/RenderFields.js +4 -2
  21. package/es/ProForm/propsType.d.ts +3 -0
  22. package/es/ProForm/style/index.less +35 -9
  23. package/es/ProForm/utils/diffOriginal.js +14 -2
  24. package/es/ProTable/components/FormatColumn/index.d.ts +2 -1
  25. package/es/ProTable/components/FormatColumn/index.js +65 -21
  26. package/es/ProTable/components/RenderColumn/index.d.ts +1 -0
  27. package/es/ProTable/components/RenderColumn/index.js +23 -6
  28. package/es/ProTable/index.js +8 -7
  29. package/es/ProTable/propsType.d.ts +4 -0
  30. package/es/ProTable/style/index.less +14 -0
  31. package/es/style/theme/antd.less +1 -1
  32. package/es/utils/index.d.ts +1 -0
  33. package/es/utils/index.js +26 -0
  34. package/lib/ProEditTable/components/RenderField/ListChangedWrapper.js +82 -21
  35. package/lib/ProEditTable/components/RenderField/index.js +6 -2
  36. package/lib/ProEditTable/index.js +18 -9
  37. package/lib/ProEditTable/propsType.d.ts +3 -6
  38. package/lib/ProEditTable/style/index.less +0 -1
  39. package/lib/ProEditTable/utils/index.js +10 -3
  40. package/lib/ProForm/components/base/InputNumber/index.js +1 -1
  41. package/lib/ProForm/components/combination/FormList/components/BlockFields.d.ts +2 -0
  42. package/lib/ProForm/components/combination/FormList/components/BlockFields.js +4 -2
  43. package/lib/ProForm/components/combination/FormList/components/LineFields.d.ts +2 -0
  44. package/lib/ProForm/components/combination/FormList/components/LineFields.js +4 -2
  45. package/lib/ProForm/components/combination/FormList/index.js +14 -3
  46. package/lib/ProForm/components/combination/Group/index.js +3 -4
  47. package/lib/ProForm/components/combination/ProCascader/index.js +21 -14
  48. package/lib/ProForm/components/combination/ProModalSelect/index.js +17 -3
  49. package/lib/ProForm/components/render/ChangedWrapper.js +29 -10
  50. package/lib/ProForm/components/render/Render.js +3 -1
  51. package/lib/ProForm/components/render/RenderFields.js +4 -2
  52. package/lib/ProForm/propsType.d.ts +3 -0
  53. package/lib/ProForm/style/index.less +35 -9
  54. package/lib/ProForm/utils/diffOriginal.js +13 -1
  55. package/lib/ProTable/components/FormatColumn/index.d.ts +2 -1
  56. package/lib/ProTable/components/FormatColumn/index.js +65 -21
  57. package/lib/ProTable/components/RenderColumn/index.d.ts +1 -0
  58. package/lib/ProTable/components/RenderColumn/index.js +20 -5
  59. package/lib/ProTable/index.js +8 -7
  60. package/lib/ProTable/propsType.d.ts +4 -0
  61. package/lib/ProTable/style/index.less +14 -0
  62. package/lib/style/theme/antd.less +1 -1
  63. package/lib/utils/index.d.ts +1 -0
  64. package/lib/utils/index.js +28 -1
  65. package/package.json +1 -1
  66. package/.vscode/extensions.json +0 -5
@@ -51,7 +51,8 @@ export var formatColumn = function formatColumn(_ref2) {
51
51
  diffToolTip = _ref2.diffToolTip,
52
52
  wrapToolTipProps = _ref2.wrapToolTipProps,
53
53
  scroll = _ref2.scroll,
54
- onUpdateMinWidth = _ref2.onUpdateMinWidth;
54
+ onUpdateMinWidth = _ref2.onUpdateMinWidth,
55
+ isInNewRow = _ref2.isInNewRow;
55
56
  var title = column.title,
56
57
  valueType = column.valueType,
57
58
  _column$format = column.format,
@@ -71,7 +72,8 @@ export var formatColumn = function formatColumn(_ref2) {
71
72
  originalDiffTip = _column$originalDiffT === void 0 ? true : _column$originalDiffT,
72
73
  _column$toolTipProps = column.toolTipProps,
73
74
  toolTipProps = _column$toolTipProps === void 0 ? {} : _column$toolTipProps,
74
- minWidth = column.minWidth;
75
+ minWidth = column.minWidth,
76
+ onDiff = column.onDiff;
75
77
  // 仅在 {x: 'max-content', y: 300 } 且 column无指定 width minWidth 情况下 才开启 minWidth的自动计算
76
78
  var isMaxContentOverFlow = isObject(scroll) ? (scroll === null || scroll === void 0 ? void 0 : scroll.x) === 'max-content' && Reflect.ownKeys(scroll).includes('y') : false;
77
79
  calcMinWidth({
@@ -108,7 +110,7 @@ export var formatColumn = function formatColumn(_ref2) {
108
110
  }
109
111
  };
110
112
  if (column === null || column === void 0 ? void 0 : column.render) {
111
- if (!originalObj && Object.keys(originalObj !== null && originalObj !== void 0 ? originalObj : {}).length === 0) {
113
+ if (!originalObj && Object.keys(originalObj !== null && originalObj !== void 0 ? originalObj : {}).length === 0 && !onDiff) {
112
114
  return;
113
115
  }
114
116
  var originalRender = column.render; // 保存原始的 render 方法
@@ -116,12 +118,27 @@ export var formatColumn = function formatColumn(_ref2) {
116
118
  column.render = function (value, record, index) {
117
119
  var _originalObj$record$r;
118
120
  var isFn = isFunction(originalRender);
119
- var _value = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(value, record !== null && record !== void 0 ? record : {}, index) : undefined;
121
+ var _value = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(value, record !== null && record !== void 0 ? record : {}, index) : null;
120
122
  var originalValue = getOriginalValue(value, record !== null && record !== void 0 ? record : {}, originalObj, rowKey, dataIndex);
121
- var originalRenderValue = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(originalValue, (_originalObj$record$r = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r !== void 0 ? _originalObj$record$r : {}, index) : undefined;
123
+ var originalRenderValue = isFn ? originalRender === null || originalRender === void 0 ? void 0 : originalRender(originalValue, (_originalObj$record$r = originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]) !== null && _originalObj$record$r !== void 0 ? _originalObj$record$r : {}, index) : null;
124
+ var isInNewRowFlag = isInNewRow(record);
125
+ var extraDiffFlag = false;
126
+ // 把比对结果告诉我
127
+ if (onDiff) {
128
+ var isDiff = onDiff({
129
+ value: record,
130
+ originValue: originalObj === null || originalObj === void 0 ? void 0 : originalObj[record === null || record === void 0 ? void 0 : record[rowKey]]
131
+ });
132
+ if (!isDiff) {
133
+ originalValue = null;
134
+ } else {
135
+ originalValue = true;
136
+ extraDiffFlag = true;
137
+ }
138
+ }
122
139
  return _jsx(RenderColumn, {
123
140
  valueType: valueType,
124
- originalValue: originalValue === undefined ? undefined : originalRenderValue,
141
+ originalValue: !originalValue && originalValue !== 0 ? null : extraDiffFlag ? originalRenderValue !== null && originalRenderValue !== void 0 ? originalRenderValue : originalValue : originalRenderValue,
125
142
  ellipsis: ellipsis,
126
143
  width: width,
127
144
  value: _value,
@@ -129,7 +146,8 @@ export var formatColumn = function formatColumn(_ref2) {
129
146
  currentValue: _value,
130
147
  originalDiffTip: _originalDiffTip,
131
148
  toolTipProps: _toolTipProps,
132
- minWidth: minWidth
149
+ minWidth: minWidth,
150
+ isInNewRowFlag: isInNewRowFlag
133
151
  });
134
152
  };
135
153
  return;
@@ -171,6 +189,7 @@ export var formatColumn = function formatColumn(_ref2) {
171
189
  size: 8,
172
190
  children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
173
191
  });
192
+ var isInNewRowFlag = isInNewRow(record);
174
193
  return _jsx(RenderColumn, {
175
194
  valueType: valueType,
176
195
  originalValue: originalValue === undefined ? undefined : originalRenderValue,
@@ -181,7 +200,8 @@ export var formatColumn = function formatColumn(_ref2) {
181
200
  currentValue: renderValue,
182
201
  originalDiffTip: _originalDiffTip,
183
202
  toolTipProps: _toolTipProps,
184
- minWidth: minWidth
203
+ minWidth: minWidth,
204
+ isInNewRowFlag: isInNewRowFlag
185
205
  });
186
206
  };
187
207
  // 千分位, 千分位带CNY前缀
@@ -207,6 +227,7 @@ export var formatColumn = function formatColumn(_ref2) {
207
227
  children: "-"
208
228
  });
209
229
  }
230
+ var isInNewRowFlag = isInNewRow(record);
210
231
  return _jsx(RenderColumn, {
211
232
  valueType: valueType,
212
233
  originalValue: originalValue === undefined ? undefined : originalRenderValue,
@@ -217,7 +238,8 @@ export var formatColumn = function formatColumn(_ref2) {
217
238
  currentValue: renderValue,
218
239
  originalDiffTip: _originalDiffTip,
219
240
  toolTipProps: _toolTipProps,
220
- minWidth: minWidth
241
+ minWidth: minWidth,
242
+ isInNewRowFlag: isInNewRowFlag
221
243
  });
222
244
  };
223
245
  } else if (['datePicker', 'date', 'dateTime', 'dateStartTime', 'dateEndTime', 'dateStartEndTime'].includes(valueType)) {
@@ -266,6 +288,7 @@ export var formatColumn = function formatColumn(_ref2) {
266
288
  children: "-"
267
289
  });
268
290
  }
291
+ var isInNewRowFlag = isInNewRow(record);
269
292
  return _jsx(RenderColumn, {
270
293
  valueType: valueType,
271
294
  originalValue: originalValue === undefined ? undefined : originalRenderValue,
@@ -276,7 +299,8 @@ export var formatColumn = function formatColumn(_ref2) {
276
299
  currentValue: renderValue,
277
300
  originalDiffTip: _originalDiffTip,
278
301
  toolTipProps: _toolTipProps,
279
- minWidth: minWidth
302
+ minWidth: minWidth,
303
+ isInNewRowFlag: isInNewRowFlag
280
304
  });
281
305
  };
282
306
  } else if (['enumName', 'enumCodeName'].includes(valueType)) {
@@ -305,6 +329,7 @@ export var formatColumn = function formatColumn(_ref2) {
305
329
  size: 8,
306
330
  children: [prefixNode(value, record, index), renderValue, suffixNode(value, record, index)]
307
331
  });
332
+ var isInNewRowFlag = isInNewRow(record);
308
333
  return _jsx(RenderColumn, {
309
334
  valueType: valueType,
310
335
  originalValue: originalValue === undefined ? undefined : originalRenderValue,
@@ -315,7 +340,8 @@ export var formatColumn = function formatColumn(_ref2) {
315
340
  currentValue: renderValue,
316
341
  originalDiffTip: _originalDiffTip,
317
342
  toolTipProps: _toolTipProps,
318
- minWidth: minWidth
343
+ minWidth: minWidth,
344
+ isInNewRowFlag: isInNewRowFlag
319
345
  });
320
346
  };
321
347
  } else if (precision || prefix || suffix) {
@@ -338,6 +364,7 @@ export var formatColumn = function formatColumn(_ref2) {
338
364
  children: "-"
339
365
  });
340
366
  }
367
+ var isInNewRowFlag = isInNewRow(record);
341
368
  return _jsx(RenderColumn, {
342
369
  valueType: valueType,
343
370
  originalValue: originalValue === undefined ? undefined : originalRenderValue,
@@ -348,7 +375,8 @@ export var formatColumn = function formatColumn(_ref2) {
348
375
  currentValue: renderValue,
349
376
  originalDiffTip: _originalDiffTip,
350
377
  toolTipProps: _toolTipProps,
351
- minWidth: minWidth
378
+ minWidth: minWidth,
379
+ isInNewRowFlag: isInNewRowFlag
352
380
  });
353
381
  };
354
382
  } else if (valueType === 'address') {
@@ -384,21 +412,32 @@ export var formatColumn = function formatColumn(_ref2) {
384
412
  code: code,
385
413
  value: originalRealValue
386
414
  });
387
- return _jsx(ProForm.ProCascader, {
415
+ var renderNode = _jsx(ProForm.ProCascader, {
388
416
  className: className,
389
417
  isView: true,
390
418
  mode: "address",
391
419
  code: code,
392
420
  value: realValue,
393
- tooltip: originalValue !== undefined ? _jsxs(_Fragment, {
394
- children: ["\u521D\u59CB\u503C\uFF1A", originalRenderValue, _jsx("br", {}), ellipsis ? _jsxs(_Fragment, {
395
- children: ["\u5F53\u524D\u503C\uFF1A", renderValue]
396
- }) : undefined]
397
- }) : ellipsis
421
+ tooltip: false
422
+ });
423
+ var isInNewRowFlag = isInNewRow(record);
424
+ return _jsx(RenderColumn, {
425
+ valueType: valueType,
426
+ originalValue: originalRealValue === undefined ? undefined : originalRenderValue,
427
+ ellipsis: ellipsis !== null && ellipsis !== void 0 ? ellipsis : true,
428
+ width: width,
429
+ node: renderNode,
430
+ value: renderValue,
431
+ currentValue: renderValue,
432
+ originalDiffTip: _originalDiffTip,
433
+ toolTipProps: _toolTipProps,
434
+ minWidth: minWidth,
435
+ isInNewRowFlag: isInNewRowFlag
398
436
  });
399
437
  };
400
438
  } else if (copyable) {
401
439
  column.render = function (value, record, index) {
440
+ var isInNewRowFlag = isInNewRow(record);
402
441
  return _jsxs(_Space, {
403
442
  size: 8,
404
443
  children: [prefixNode(value, record, index), _jsx(RenderColumn, {
@@ -410,7 +449,8 @@ export var formatColumn = function formatColumn(_ref2) {
410
449
  value: value,
411
450
  currentValue: value,
412
451
  toolTipProps: _toolTipProps,
413
- minWidth: minWidth
452
+ minWidth: minWidth,
453
+ isInNewRowFlag: isInNewRowFlag
414
454
  }), suffixNode(value, record, index)]
415
455
  });
416
456
  };
@@ -425,6 +465,7 @@ export var formatColumn = function formatColumn(_ref2) {
425
465
  children: "-"
426
466
  });
427
467
  }
468
+ var isInNewRowFlag = isInNewRow(record);
428
469
  return _jsxs(_Space, {
429
470
  size: 8,
430
471
  children: [prefixNode(value, record, index), _jsx(RenderColumn, {
@@ -437,7 +478,8 @@ export var formatColumn = function formatColumn(_ref2) {
437
478
  currentValue: value || '-',
438
479
  originalDiffTip: _originalDiffTip,
439
480
  toolTipProps: _toolTipProps,
440
- minWidth: minWidth
481
+ minWidth: minWidth,
482
+ isInNewRowFlag: isInNewRowFlag
441
483
  }), suffixNode(value, record, index)]
442
484
  });
443
485
  };
@@ -456,6 +498,7 @@ export var formatColumn = function formatColumn(_ref2) {
456
498
  children: "-"
457
499
  });
458
500
  }
501
+ var isInNewRowFlag = isInNewRow(record);
459
502
  return _jsx(RenderColumn, {
460
503
  valueType: valueType,
461
504
  originalValue: originalValue === undefined ? undefined : originalValue || '-',
@@ -466,7 +509,8 @@ export var formatColumn = function formatColumn(_ref2) {
466
509
  currentValue: value || '-',
467
510
  originalDiffTip: _originalDiffTip,
468
511
  toolTipProps: _toolTipProps,
469
- minWidth: minWidth
512
+ minWidth: minWidth,
513
+ isInNewRowFlag: isInNewRowFlag
470
514
  });
471
515
  };
472
516
  }
@@ -12,6 +12,7 @@ interface Props {
12
12
  originalValue?: any;
13
13
  toolTipProps?: TooltipProps & React.RefAttributes<unknown>;
14
14
  minWidth?: number;
15
+ isInNewRowFlag?: boolean;
15
16
  }
16
17
  declare const RenderColumn: FC<Props>;
17
18
  export default RenderColumn;
@@ -1,10 +1,12 @@
1
+ import "antd/es/space/style";
2
+ import _Space from "antd/es/space";
1
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
4
  import "antd/es/tooltip/style";
3
5
  import _Tooltip from "antd/es/tooltip";
4
6
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
7
  import "antd/es/typography/style";
6
8
  import _Typography from "antd/es/typography";
7
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
9
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
10
  import { useSetState } from 'ahooks';
9
11
  import { CheckOutlined } from '@ant-design/icons';
10
12
  import { ReactSVG } from 'react-svg';
@@ -24,14 +26,15 @@ var RenderColumn = function RenderColumn(props) {
24
26
  originalDiffTip = props.originalDiffTip,
25
27
  _props$toolTipProps = props.toolTipProps,
26
28
  toolTipProps = _props$toolTipProps === void 0 ? {} : _props$toolTipProps,
27
- minWidth = props.minWidth;
29
+ minWidth = props.minWidth,
30
+ isInNewRowFlag = props.isInNewRowFlag;
28
31
  var _useSetState = useSetState({
29
32
  tooltip: false
30
33
  }),
31
34
  _useSetState2 = _slicedToArray(_useSetState, 2),
32
35
  tooltip = _useSetState2[0].tooltip,
33
36
  setState = _useSetState2[1];
34
- if (originalValue !== undefined) {
37
+ if ((originalValue || originalValue === 0) && !isInNewRowFlag) {
35
38
  var renderNode = value ? node : '-';
36
39
  if (ellipsis || originalDiffTip) {
37
40
  if (ellipsis) {
@@ -52,9 +55,23 @@ var RenderColumn = function RenderColumn(props) {
52
55
  width: width,
53
56
  minWidth: minWidth
54
57
  },
55
- title: originalDiffTip ? _jsxs(_Fragment, {
56
- children: ["\u521D\u59CB\u503C\uFF1A", originalValue, _jsx("br", {}), ellipsis ? "\u5F53\u524D\u503C\uFF1A".concat(currentValue) : undefined]
57
- }) : node,
58
+ overlayClassName: "original-value-tootip",
59
+ title: _jsx(_Space, {
60
+ direction: "vertical",
61
+ className: "changed-tooltip",
62
+ children: originalDiffTip ? _jsxs(_Fragment, {
63
+ children: [_jsxs(_Space, {
64
+ align: "start",
65
+ className: "original-value-container",
66
+ children: ["\u521D\u59CB\u503C\uFF1A", originalValue]
67
+ }), _jsx(_Space, {
68
+ className: "current-value-container",
69
+ children: ellipsis ? _jsxs("span", {
70
+ children: ["\u5F53\u524D\u503C\uFF1A", currentValue]
71
+ }) : null
72
+ })]
73
+ }) : node
74
+ }),
58
75
  getPopupContainer: function getPopupContainer(triggerNode) {
59
76
  return triggerNode.parentNode;
60
77
  }
@@ -183,6 +183,11 @@ function ProTable(props) {
183
183
  setCurColumns(nextColumns);
184
184
  };
185
185
  };
186
+ var _rowClassName = function _rowClassName(record, index) {
187
+ if (originalDataSource && !originalObj.hasOwnProperty(get(record, 'rowKey'))) {
188
+ return 'new-cell';
189
+ }
190
+ };
186
191
  var columns = useMemo(function () {
187
192
  var newColumns = curColumns.map(function (item, index) {
188
193
  var _propsColumnObj$getCo2;
@@ -215,11 +220,12 @@ function ProTable(props) {
215
220
  scroll: _scroll,
216
221
  onUpdateMinWidth: function onUpdateMinWidth(w) {
217
222
  curColumns[index].minWidth = w;
218
- }
223
+ },
224
+ isInNewRow: _rowClassName
219
225
  });
220
226
  });
221
227
  return newColumns;
222
- }, [curColumns, handleResize, _scroll]);
228
+ }, [curColumns, handleResize, _scroll, originalDataSource, originalObj, _rowClassName]);
223
229
  var _columns = useMemo(function () {
224
230
  return columns === null || columns === void 0 ? void 0 : columns.filter(function (item, index) {
225
231
  var show = item.show;
@@ -368,11 +374,6 @@ function ProTable(props) {
368
374
  return _ref7.apply(this, arguments);
369
375
  };
370
376
  }();
371
- var _rowClassName = function _rowClassName(record, index) {
372
- if (originalDataSource && !originalObj.hasOwnProperty(get(record, 'rowKey'))) {
373
- return 'new-cell';
374
- }
375
- };
376
377
  var TableComponent = draggable ? DraggableTable : BaseTable;
377
378
  // 标记样式
378
379
  var tagStyle = {
@@ -41,6 +41,10 @@ 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
  show?: boolean | (() => boolean);
44
+ onDiff?: ({ value, originValue }: {
45
+ value: any;
46
+ originValue: any;
47
+ }) => boolean;
44
48
  }
45
49
  export interface CreateTreeFromArrayOptions {
46
50
  itemKey?: string;
@@ -272,8 +272,22 @@
272
272
  .@{ant-prefix}-table-cell .varied-cell {
273
273
  margin-left: -8px;
274
274
  padding: var(--zaui-space-size-xs, 4px) var(--zaui-space-size-sm, 8px);
275
+
275
276
  background: var(--zaui-contract-bg; #fffaa1) !important;
276
277
  border-radius: var(--zaui-border-radius, 8px);
278
+ .pro-form-view-container {
279
+ overflow: hidden;
280
+ white-space: nowrap;
281
+ text-overflow: ellipsis;
282
+ }
283
+ }
284
+
285
+ .@{ant-prefix}-table-cell .@{ant-prefix}-typography-ellipsis {
286
+ .pro-form-view-container {
287
+ overflow: hidden;
288
+ white-space: nowrap;
289
+ text-overflow: ellipsis;
290
+ }
277
291
  }
278
292
 
279
293
  .varied-cell.empty-cell {
@@ -323,7 +323,7 @@
323
323
  .@{ant-prefix}-table-tbody {
324
324
  .@{ant-prefix}-table-row:nth-child(even) {
325
325
  td {
326
- background: #ffffff !important;
326
+ background: #ffffff;
327
327
  }
328
328
  }
329
329
 
@@ -1,2 +1,3 @@
1
1
  /** 判断一个值是否是空值 */
2
2
  export declare const isEmpty: (value: any) => boolean;
3
+ export declare const useFocus: (element: Element) => boolean;
package/es/utils/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useEffect, useState } from 'react';
1
3
  var EMPTY_VALUE = [undefined, null, ''];
2
4
  /** 判断一个值是否是空值 */
3
5
  export var isEmpty = function isEmpty(value) {
@@ -10,4 +12,28 @@ export var isEmpty = function isEmpty(value) {
10
12
  });
11
13
  }
12
14
  return false;
15
+ };
16
+ export var useFocus = function useFocus(element) {
17
+ var _useState = useState(false),
18
+ _useState2 = _slicedToArray(_useState, 2),
19
+ focus = _useState2[0],
20
+ setFocus = _useState2[1];
21
+ useEffect(function () {
22
+ if (!element) return;
23
+ element.addEventListener('focus', function () {
24
+ setFocus(true);
25
+ }, true);
26
+ element.addEventListener('blur', function () {
27
+ setFocus(false);
28
+ }, true);
29
+ return function () {
30
+ element.removeEventListener('focus', function () {
31
+ setFocus(true);
32
+ }, true);
33
+ element.removeEventListener('blur', function () {
34
+ setFocus(false);
35
+ }, true);
36
+ };
37
+ }, [element]);
38
+ return focus;
13
39
  };
@@ -17,7 +17,7 @@ var _lodash = require("lodash");
17
17
  var _diffOriginal = require("../../../ProForm/utils/diffOriginal");
18
18
  var _ProConfigProvider = require("../../../ProConfigProvider");
19
19
  var _utils = require("../../../utils");
20
- var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName"];
20
+ var _excluded = ["name", "names", "namesStr", "originalName", "originalNames", "originalValues", "form", "equalWith", "rowKeyPath", "children", "type", "normalize", "getValueProps", "valuePropName", "viewRender", "diffConfig", "index"];
21
21
  var toNamePath = function toNamePath(name) {
22
22
  if (Array.isArray(name)) {
23
23
  return name;
@@ -39,6 +39,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
39
39
  if (!originalValues) {
40
40
  return undefined;
41
41
  }
42
+ var originalValueRow;
42
43
  if (rowKeyPath) {
43
44
  var rowValueNamePath = namePath.slice(0, rowKeyPath.length - 1); // 表单中变动值所在行
44
45
  var rowKeyName = rowKeyPath[rowKeyPath.length - 1]; // rowKey在行内的name
@@ -47,7 +48,7 @@ var getOriginalValue = function getOriginalValue(_ref) {
47
48
  var keyValue = rowValue[rowKeyName]; // 获取表单中rowKey值
48
49
  if (!keyValue) return undefined;
49
50
  var originalValueList = (0, _lodash.get)(originalValues, originalName.slice(0, rowKeyPath.length - 2));
50
- var originalValueRow = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
51
+ originalValueRow = originalValueList === null || originalValueList === void 0 ? void 0 : originalValueList.find(function (item) {
51
52
  return item[rowKeyPath[rowKeyPath.length - 1]] === keyValue;
52
53
  });
53
54
  var originalValue;
@@ -63,15 +64,21 @@ var getOriginalValue = function getOriginalValue(_ref) {
63
64
  } else {
64
65
  originalValue = (0, _lodash.get)(originalValueRow, originalName.slice(rowKeyPath.length - 1));
65
66
  }
66
- return originalValue;
67
+ return {
68
+ originalValue: originalValue,
69
+ originalValueRow: originalValueRow
70
+ };
67
71
  }
68
72
  // 这个方法是给editTable专用的 暂时不存在不传rowKey的情况
69
- return (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
70
- return (0, _lodash.get)(originalValues, originalName);
71
- }) : (0, _lodash.get)(originalValues, originalName);
73
+ return {
74
+ originalValue: (originalNames === null || originalNames === void 0 ? void 0 : originalNames.length) ? originalNames.map(function (originalName) {
75
+ return (0, _lodash.get)(originalValues, originalName);
76
+ }) : (0, _lodash.get)(originalValues, originalName),
77
+ originalValueRow: originalValueRow
78
+ };
72
79
  };
73
80
  var ListChangedWrapper = function ListChangedWrapper(props) {
74
- var _getValueProps;
81
+ var _diffConfig$toolTip, _children$props, _children$props2, _children$props3;
75
82
  var name = props.name,
76
83
  names = props.names,
77
84
  namesStr = props.namesStr,
@@ -89,21 +96,30 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
89
96
  getValueProps = props.getValueProps,
90
97
  _props$valuePropName = props.valuePropName,
91
98
  valuePropName = _props$valuePropName === void 0 ? 'value' : _props$valuePropName,
99
+ viewRender = props.viewRender,
100
+ diffConfig = props.diffConfig,
101
+ index = props.index,
92
102
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
93
103
  var _ref2 = (0, _ProConfigProvider.useProConfig)('ProEditTable') || {},
94
104
  isDiffAll = _ref2.isDiffAll;
105
+ var _ref3 = diffConfig || {},
106
+ _ref3$scrollFollowPar = _ref3.scrollFollowParent,
107
+ scrollFollowParent = _ref3$scrollFollowPar === void 0 ? true : _ref3$scrollFollowPar;
108
+ var contentRef = (0, _react.useRef)(null);
95
109
  var namePath = toNamePath(namesStr || name);
96
110
  var originalNamePath = toNamePath(originalName);
97
111
  var originalNamePaths = originalNames && toNamePaths(originalNames);
112
+ var toolTip = (_diffConfig$toolTip = diffConfig === null || diffConfig === void 0 ? void 0 : diffConfig.toolTip) !== null && _diffConfig$toolTip !== void 0 ? _diffConfig$toolTip : true;
98
113
  var isWatch = Boolean(originalValues);
99
- var originalValue = isWatch ? getOriginalValue({
114
+ var originalDTO = getOriginalValue({
100
115
  namePath: namePath,
101
116
  originalName: originalNamePath,
102
117
  originalNames: originalNamePaths,
103
118
  originalValues: originalValues,
104
119
  rowKeyPath: rowKeyPath,
105
120
  form: form
106
- }) : undefined;
121
+ });
122
+ var originalValue = isWatch ? originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValue : undefined;
107
123
  var noChange = !equalWith && (!originalValues || isDiffAll ? false : (0, _utils.isEmpty)(originalValue));
108
124
  var diffType = (0, _react.useMemo)(function () {
109
125
  if (!isWatch || noChange) return 'same';
@@ -118,30 +134,75 @@ var ListChangedWrapper = function ListChangedWrapper(props) {
118
134
  }, [props[valuePropName], originalValue]);
119
135
  var isAdd = diffType === 'add';
120
136
  var isChanged = diffType === 'changed';
137
+ var tipContent = (0, _react.useMemo)(function () {
138
+ var _getValueProps;
139
+ if (!isWatch || noChange) return undefined;
140
+ var orgValue = getValueProps && !names ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : originalValue;
141
+ // 兼容viewRender函数和Element场景
142
+ var _children = children;
143
+ if (viewRender) {
144
+ if (! /*#__PURE__*/_react.default.isValidElement(viewRender)) {
145
+ return viewRender(orgValue, (originalDTO === null || originalDTO === void 0 ? void 0 : originalDTO.originalValueRow) || {}, {
146
+ form: form,
147
+ name: name,
148
+ index: index
149
+ });
150
+ }
151
+ _children = viewRender;
152
+ }
153
+ return /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({
154
+ // @ts-ignore
155
+ isView: true
156
+ }, valuePropName, orgValue), "checked", type === 'Switch' ? originalValue : undefined))) : undefined;
157
+ }, [originalValue, children]);
121
158
  if (!isWatch || noChange) {
122
159
  return /*#__PURE__*/_react.default.isValidElement(children) && /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest));
123
160
  }
161
+ // eslint-disable-next-line react-hooks/rules-of-hooks
162
+ // const isFocus = useFocus(contentRef.current);
163
+ var tipOpenCalc = function tipOpenCalc() {
164
+ if (!toolTip) return false;
165
+ // 传入undefined 鼠标移入显示移出隐藏
166
+ return isChanged ? undefined : false;
167
+ };
168
+ // @ts-ignore
169
+ var _showEllipse = ((_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props.showEllipse) || ((_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2.tooltip);
124
170
  var diffClassName = (0, _classnames.default)({
125
171
  'pro-form-item-changed': isChanged,
126
172
  'pro-form-item-add': isAdd
127
173
  });
128
- return (0, _jsxRuntime.jsx)(_antd.Tooltip
129
- // 传入undefined 鼠标移入显示移出隐藏
130
- , {
131
- // 传入undefined 鼠标移入显示移出隐藏
132
- open: isChanged ? undefined : false,
133
- getPopupContainer: function getPopupContainer(target) {
134
- return target.parentElement;
174
+ var open = tipOpenCalc();
175
+ return (0, _jsxRuntime.jsx)(_antd.Tooltip, {
176
+ open: open,
177
+ getPopupContainer: function getPopupContainer(trigger) {
178
+ return scrollFollowParent ? trigger.parentElement : document.body;
135
179
  },
180
+ overlayClassName: "original-value-tootip",
181
+ placement: "topLeft",
182
+ autoAdjustOverflow: false,
136
183
  title: (0, _jsxRuntime.jsxs)(_antd.Space, {
137
- children: ["\u521D\u59CB\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children), {}, (0, _defineProperty2.default)((0, _defineProperty2.default)({
138
- // @ts-ignore
139
- isView: true
140
- }, valuePropName, getValueProps ? (_getValueProps = getValueProps(originalValue)) === null || _getValueProps === void 0 ? void 0 : _getValueProps[valuePropName] : props[valuePropName]), "checked", type === 'Switch' ? originalValue : undefined))) : undefined]
184
+ direction: "vertical",
185
+ className: "changed-tooltip",
186
+ children: [(0, _jsxRuntime.jsxs)(_antd.Space, {
187
+ align: "start",
188
+ className: "original-value-container",
189
+ children: ["\u521D\u59CB\u503C\uFF1A", tipContent]
190
+ }), _showEllipse && (0, _jsxRuntime.jsxs)(_antd.Space, {
191
+ className: "current-value-container",
192
+ children: ["\u5F53\u524D\u503C\uFF1A", /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
193
+ isView: true,
194
+ scrollFollowParent: scrollFollowParent
195
+ })) : undefined]
196
+ })]
141
197
  }),
142
198
  children: (0, _jsxRuntime.jsx)("div", {
143
199
  className: diffClassName,
144
- children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest)) : undefined
200
+ children: /*#__PURE__*/_react.default.isValidElement(children) ? /*#__PURE__*/_react.default.cloneElement(children, (0, _objectSpread3.default)((0, _objectSpread3.default)((0, _objectSpread3.default)({}, children.props), rest), {}, {
201
+ scrollFollowParent: scrollFollowParent,
202
+ otherProps: (0, _objectSpread3.default)((0, _objectSpread3.default)({}, (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3.otherProps), {}, {
203
+ isDiffChange: isChanged
204
+ })
205
+ })) : undefined
145
206
  })
146
207
  });
147
208
  };
@@ -80,7 +80,8 @@ var RenderField = function RenderField(_ref) {
80
80
  rowDisabled = config.rowDisabled,
81
81
  _config$validateTrigg = config.validateTrigger,
82
82
  validateTrigger = _config$validateTrigg === void 0 ? ['onChange', 'onBlur', 'onSubmit'] : _config$validateTrigg,
83
- otherProps = config.otherProps;
83
+ otherProps = config.otherProps,
84
+ diffConfig = config.diffConfig;
84
85
  var _fieldProps = fieldProps || formItemProps || {};
85
86
  var _rules = rules || [];
86
87
  var _required = required;
@@ -261,7 +262,7 @@ var RenderField = function RenderField(_ref) {
261
262
  if (typeof viewRender === 'function') {
262
263
  var _column$dataIndex;
263
264
  currentValue = (column === null || column === void 0 ? void 0 : (_column$dataIndex = column.dataIndex) === null || _column$dataIndex === void 0 ? void 0 : _column$dataIndex.includes('-')) ? value : currentValue;
264
- var View = viewRender(currentValue, record, options);
265
+ var View = viewRender(currentValue, record || {}, options);
265
266
  TargetComponent = (0, _jsxRuntime.jsx)(_Container.default, {
266
267
  viewEmpty: viewEmpty,
267
268
  children: View
@@ -567,6 +568,9 @@ var RenderField = function RenderField(_ref) {
567
568
  valuePropName: _formItemProps.valuePropName,
568
569
  normalize: _formItemProps.normalize,
569
570
  getValueProps: _formItemProps.getValueProps,
571
+ viewRender: viewRender,
572
+ diffConfig: diffConfig,
573
+ index: index,
570
574
  children: FieldComponent
571
575
  });
572
576
  }