@zat-design/sisyphus-react 4.1.2-beta.1 → 4.1.2-beta.10

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 (52) hide show
  1. package/.claudeignore +40 -0
  2. package/dist/index.esm.css +1 -1
  3. package/dist/less.esm.css +1 -1
  4. package/es/ProEditTable/components/RcTable/BaseTable.js +12 -16
  5. package/es/ProEditTable/components/RcTable/DraggableTable.js +11 -16
  6. package/es/ProEditTable/components/RenderField/index.js +292 -97
  7. package/es/ProEditTable/index.js +14 -4
  8. package/es/ProEditTable/propsType.d.ts +6 -1
  9. package/es/ProEditTable/style/index.less +8 -0
  10. package/es/ProEditTable/utils/index.js +66 -24
  11. package/es/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
  12. package/es/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
  13. package/es/ProForm/components/base/DatePicker/index.js +1 -7
  14. package/es/ProForm/components/base/RangePicker/index.js +62 -8
  15. package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
  16. package/es/ProForm/components/combination/Group/component/ComRender.js +15 -11
  17. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
  18. package/es/ProForm/components/combination/Group/style/index.less +26 -1
  19. package/es/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
  20. package/es/ProForm/propsType.d.ts +3 -3
  21. package/es/ProForm/utils/transformValue.d.ts +1 -1
  22. package/es/ProForm/utils/useForm.d.ts +1 -1
  23. package/es/ProForm/utils/useWatch.d.ts +2 -1
  24. package/es/ProForm/utils/useWatch.js +3 -1
  25. package/es/ProSelect/index.js +117 -62
  26. package/es/ProUpload/propsType.d.ts +1 -1
  27. package/es/ProUpload/style/index.less +3 -3
  28. package/lib/ProEditTable/components/RcTable/BaseTable.js +11 -15
  29. package/lib/ProEditTable/components/RcTable/DraggableTable.js +11 -16
  30. package/lib/ProEditTable/components/RenderField/index.js +292 -97
  31. package/lib/ProEditTable/index.js +14 -4
  32. package/lib/ProEditTable/propsType.d.ts +6 -1
  33. package/lib/ProEditTable/style/index.less +8 -0
  34. package/lib/ProEditTable/utils/index.js +67 -23
  35. package/lib/ProEditTable/utils/useShouldUpdateForTable.d.ts +1 -0
  36. package/lib/ProEditTable/utils/useShouldUpdateForTable.js +37 -10
  37. package/lib/ProForm/components/base/DatePicker/index.js +1 -7
  38. package/lib/ProForm/components/base/RangePicker/index.js +62 -8
  39. package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
  40. package/lib/ProForm/components/combination/Group/component/ComRender.js +15 -11
  41. package/lib/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
  42. package/lib/ProForm/components/combination/Group/style/index.less +26 -1
  43. package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
  44. package/lib/ProForm/propsType.d.ts +3 -3
  45. package/lib/ProForm/utils/transformValue.d.ts +1 -1
  46. package/lib/ProForm/utils/useForm.d.ts +1 -1
  47. package/lib/ProForm/utils/useWatch.d.ts +2 -1
  48. package/lib/ProForm/utils/useWatch.js +3 -1
  49. package/lib/ProSelect/index.js +115 -61
  50. package/lib/ProUpload/propsType.d.ts +1 -1
  51. package/lib/ProUpload/style/index.less +3 -3
  52. package/package.json +4 -2
@@ -278,7 +278,9 @@ var ProEditTable = (_ref, ref) => {
278
278
  getIsNew,
279
279
  handlePageChange
280
280
  }, resetProps);
281
- }, [actionDirection, actionProps, actionWidth, cellNamePath, deletePoConfirmMsg, disabled, diffConfig, editingKeys, emptyBtnText, form, forceUpdate, getIsNew, handlePageChange, insertType, isView, max, mode, mulDeletePoConfirmMsg, name, namePath, onlyOneLineMsg, originalValues, prefixCls, requiredAlign, resetProps, rowDisabled, selectedRowKeys, selectedRows, shouldUpdateDebounce, tableRef, toolbarProps, value === null || value === void 0 ? void 0 : value.length, viewEmpty, virtualKey, page]);
281
+ }, [actionDirection, actionProps, actionWidth, cellNamePath, deletePoConfirmMsg, disabled, diffConfig, editingKeys, emptyBtnText, form,
282
+ // forceUpdate 不应该作为依赖项,因为它是触发刷新的信号,而非用于比较的数据
283
+ getIsNew, handlePageChange, insertType, isView, max, mode, mulDeletePoConfirmMsg, name, namePath, onlyOneLineMsg, originalValues, prefixCls, requiredAlign, resetProps, rowDisabled, selectedRowKeys, selectedRows, shouldUpdateDebounce, tableRef, toolbarProps, value === null || value === void 0 ? void 0 : value.length, viewEmpty, virtualKey, page]);
282
284
 
283
285
  // 编辑行设置下样式
284
286
  var _rowClassName = record => {
@@ -373,7 +375,7 @@ var ProEditTable = (_ref, ref) => {
373
375
  };
374
376
  var _columns = useMemo(() => {
375
377
  return transformColumns(columns, config);
376
- }, [columns, config]);
378
+ }, [disabled, forceUpdate, columns, page, actionProps, editingKeys, cellNamePath, config]);
377
379
  var initDataSource = () => {
378
380
  var _value$every, _value$some;
379
381
  // 检查每一项是否有 rowKey 或通过 rowKey 字段获取的 key
@@ -422,9 +424,17 @@ var ProEditTable = (_ref, ref) => {
422
424
  rowSelection: renderRowSelection()
423
425
  }) : summary;
424
426
  var TableComponent = draggable ? DraggableTable : BaseTable;
427
+
428
+ // 给每个 record 附加编辑状态标识,让 shouldCellUpdate 能检测到状态变化
429
+ var enrichedValue = useMemo(() => {
430
+ if (!virtualKey) return value;
431
+ return value === null || value === void 0 ? void 0 : value.map(record => _objectSpread(_objectSpread({}, record), {}, {
432
+ _isEditing: editingKeys.includes(record.rowKey) || record._addFlag
433
+ }));
434
+ }, [value, virtualKey, editingKeys]);
425
435
  var tableProps = useMemo(() => ({
426
436
  rowKey,
427
- value,
437
+ value: enrichedValue,
428
438
  headerRender,
429
439
  tableRef,
430
440
  className: _className,
@@ -443,7 +453,7 @@ var ProEditTable = (_ref, ref) => {
443
453
  formatMessage,
444
454
  locale,
445
455
  handlePageChange
446
- }), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale, page, pagination, renderRowSelection, rowDraggable, rowKey, scroll, _summary, tableRef, value, virtualKey]);
456
+ }), [_className, _columns, _rowClassName, disabled, editingKeys, formatMessage, handlePageChange, headerRender, isHideCheckBox, locale, page, pagination, renderRowSelection, rowDraggable, rowKey, scroll, _summary, tableRef, enrichedValue, virtualKey]);
447
457
  return /*#__PURE__*/_jsxs(_Fragment, {
448
458
  children: [/*#__PURE__*/_jsx(ConfigProvider, {
449
459
  renderEmpty: value !== null && value !== void 0 && value.length ? undefined : emptyDom,
@@ -130,6 +130,11 @@ export type RequiredFn<T = any> = ReactiveFunction<T, boolean | boolean[]>;
130
130
  * @template T 记录类型
131
131
  */
132
132
  export type viewRenderFn<T = any> = (text?: any, record?: T, options?: OptionsProps) => string | number | ReactNode | void;
133
+ /**
134
+ * 组件渲染函数类型(与 ReactiveFunction 保持一致)
135
+ * @template T 记录类型
136
+ */
137
+ export type ComponentRenderFn<T = any> = ReactiveFunction<T, string | number | ReactNode | void>;
133
138
  /**
134
139
  * 表格列属性接口
135
140
  * @template Values 值类型
@@ -153,7 +158,7 @@ export interface ProColumnsProps<Values = any, T = any> extends Omit<FormItemPro
153
158
  icon?: string | ReactNode;
154
159
  } & TooltipProps);
155
160
  /** 组件 */
156
- component?: string | number | ReactNode | viewRenderFn<T>;
161
+ component?: string | number | ReactNode | ComponentRenderFn<T>;
157
162
  /** 视图渲染 */
158
163
  viewRender?: string | number | ReactNode | viewRenderFn<T>;
159
164
  /** 隐藏的字段名 */
@@ -425,4 +425,12 @@
425
425
  table tr th.@{ant-prefix}-table-selection-column.@{ant-prefix}-table-cell-fix-start{
426
426
  text-align: right;
427
427
  }
428
+ table .@{ant-prefix}-table-thead{
429
+ th.@{ant-prefix}-table-selection-column.@{ant-prefix}-table-cell-fix-start{
430
+ text-align: left;
431
+ .@{ant-prefix}-table-selection{
432
+ padding-left: 27px;
433
+ }
434
+ }
435
+ }
428
436
  }
@@ -22,10 +22,13 @@ import { filterInternalFields } from "../../ProForm/utils";
22
22
  import ProTooltip from "../../ProTooltip";
23
23
  import { RenderField, ActionButton } from "../components";
24
24
  import locale from "../../locale";
25
-
26
- // 渲染操作栏
27
25
  import { jsx as _jsx } from "react/jsx-runtime";
28
26
  import { jsxs as _jsxs } from "react/jsx-runtime";
27
+ var columnDataSourceRefCache = new Map();
28
+ /** 追踪 component 函数引用,用于检测外部状态(如异步 list)变化导致的闭包更新 */
29
+ var columnComponentRefCache = new Map();
30
+
31
+ // 渲染操作栏
29
32
  var getActionColumn = config => {
30
33
  var _cloneDeepWith = cloneDeepWith(config, value => {
31
34
  if ( /*#__PURE__*/React.isValidElement(value)) {
@@ -41,7 +44,8 @@ var getActionColumn = config => {
41
44
  actionProps = _cloneDeepWith.actionProps,
42
45
  page = _cloneDeepWith.page,
43
46
  rowDisabled = _cloneDeepWith.rowDisabled,
44
- actionDirection = _cloneDeepWith.actionDirection;
47
+ actionDirection = _cloneDeepWith.actionDirection,
48
+ editingKeys = _cloneDeepWith.editingKeys;
45
49
  var pageNum = tools.calc(page.pageNum, '-', 1);
46
50
  var firstIndex = tools.calc(pageNum, '*', page.pageSize);
47
51
  // actionProps配置为false 默认不插入
@@ -89,7 +93,7 @@ var getActionColumn = config => {
89
93
  action.onEvent = /*#__PURE__*/function () {
90
94
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
91
95
  var _form$getFieldValue;
92
- var index, form, name, namePath, tableLength, selectedRows, rowName, lastRecord, onEvent, result, actionHandler;
96
+ var index, form, name, namePath, tableLength, selectedRows, rowName, _isEditing, lastRecord, onEvent, result, actionHandler;
93
97
  return _regeneratorRuntime().wrap(function _callee$(_context) {
94
98
  while (1) switch (_context.prev = _context.next) {
95
99
  case 0:
@@ -97,33 +101,39 @@ var getActionColumn = config => {
97
101
  index = tools.calc(firstIndex, '+', index);
98
102
  rowName = [...virtualRowName, index];
99
103
  if (!(type === 'save')) {
100
- _context.next = 13;
104
+ _context.next = 15;
101
105
  break;
102
106
  }
103
- _context.prev = 4;
104
- _context.next = 7;
107
+ // 判断该行是否处于编辑状态
108
+ _isEditing = !virtualKey || editingKeys.includes(record.rowKey) || record._addFlag; // 只有编辑中的行才需要校验
109
+ if (!_isEditing) {
110
+ _context.next = 15;
111
+ break;
112
+ }
113
+ _context.prev = 6;
114
+ _context.next = 9;
105
115
  return customValidate(validateKeys, form, rowName);
106
- case 7:
107
- _context.next = 13;
108
- break;
109
116
  case 9:
110
- _context.prev = 9;
111
- _context.t0 = _context["catch"](4);
117
+ _context.next = 15;
118
+ break;
119
+ case 11:
120
+ _context.prev = 11;
121
+ _context.t0 = _context["catch"](6);
112
122
  handleScrollToError();
113
123
  return _context.abrupt("return", Promise.reject(_context.t0));
114
- case 13:
124
+ case 15:
115
125
  // 编辑状态使用自定义form值,非编辑状态直接使用行数据
116
126
  lastRecord = filterInternalFields((_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record); // 新增事件可以设置初始默认值,当做函数的出参导出
117
127
  onEvent = onClick || onHandle;
118
128
  if (onEvent) {
119
- _context.next = 19;
129
+ _context.next = 21;
120
130
  break;
121
131
  }
122
132
  result = true;
123
- _context.next = 22;
133
+ _context.next = 24;
124
134
  break;
125
- case 19:
126
- _context.next = 21;
135
+ case 21:
136
+ _context.next = 23;
127
137
  return onEvent === null || onEvent === void 0 ? void 0 : onEvent(lastRecord, {
128
138
  form,
129
139
  index,
@@ -132,9 +142,9 @@ var getActionColumn = config => {
132
142
  namePath,
133
143
  selectedRows
134
144
  });
135
- case 21:
145
+ case 23:
136
146
  result = _context.sent;
137
- case 22:
147
+ case 24:
138
148
  if (result !== false && type !== 'custom') {
139
149
  actionHandler = actions[type];
140
150
  actionHandler(_objectSpread(_objectSpread({}, config), {}, {
@@ -145,11 +155,11 @@ var getActionColumn = config => {
145
155
  validateKeys
146
156
  }));
147
157
  }
148
- case 23:
158
+ case 25:
149
159
  case "end":
150
160
  return _context.stop();
151
161
  }
152
- }, _callee, null, [[4, 9]]);
162
+ }, _callee, null, [[6, 11]]);
153
163
  }));
154
164
  return function (_x, _x2) {
155
165
  return _ref2.apply(this, arguments);
@@ -368,13 +378,45 @@ export var transformColumns = function transformColumns() {
368
378
  // 精准控制单元格更新,减少不必要的渲染
369
379
  if (!item.shouldCellUpdate) {
370
380
  var hasComponent = isFunction(item.component);
381
+ var columnCacheKey = `${Array.isArray(name) ? name.join('.') : String(name)}::${String(columnName)}`;
371
382
  item.shouldCellUpdate = (record, prevRecord) => {
372
- if ((record === null || record === void 0 ? void 0 : record.rowKey) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord.rowKey)) return true;
383
+ var _item$fieldProps;
384
+ var currentDataSourceRef = !isFunction(item === null || item === void 0 ? void 0 : item.fieldProps) ? item === null || item === void 0 || (_item$fieldProps = item.fieldProps) === null || _item$fieldProps === void 0 ? void 0 : _item$fieldProps.dataSource : undefined;
385
+ if (currentDataSourceRef !== undefined) {
386
+ var prevDataSourceRef = columnDataSourceRefCache.get(columnCacheKey);
387
+ if (prevDataSourceRef !== currentDataSourceRef) {
388
+ columnDataSourceRefCache.set(columnCacheKey, currentDataSourceRef);
389
+ return true;
390
+ }
391
+ }
392
+ if ((record === null || record === void 0 ? void 0 : record.rowKey) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord.rowKey)) {
393
+ return true;
394
+ }
395
+ // 单行编辑模式下,需要检测编辑状态变化
396
+ if (virtualKey && (record === null || record === void 0 ? void 0 : record._isEditing) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord._isEditing)) {
397
+ return true;
398
+ }
373
399
  // 动态 component 可能依赖行内其他字段,需比较整行
374
- if (hasComponent) return !isEqual(record, prevRecord);
400
+ if (hasComponent) {
401
+ // component 函数引用变化说明外部依赖(如异步 list)已更新,必须重渲染
402
+ // 即使行数据未变,旧闭包仍持有过时的外部状态
403
+ var prevComponentRef = columnComponentRefCache.get(columnCacheKey);
404
+ var currentComponentRef = item.component;
405
+ if (prevComponentRef !== currentComponentRef) {
406
+ columnComponentRefCache.set(columnCacheKey, currentComponentRef);
407
+ return true;
408
+ }
409
+ // 同引用时 isEqual 恒为 true,无法感知原地修改,必须重渲染
410
+ if (record === prevRecord) {
411
+ return true;
412
+ }
413
+ var rowChanged = !isEqual(record, prevRecord);
414
+ return rowChanged;
415
+ }
375
416
  var key = item.dataIndex || item.key;
376
417
  if (!key) return true;
377
- return (record === null || record === void 0 ? void 0 : record[key]) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord[key]);
418
+ var keyChanged = (record === null || record === void 0 ? void 0 : record[key]) !== (prevRecord === null || prevRecord === void 0 ? void 0 : prevRecord[key]);
419
+ return keyChanged;
378
420
  };
379
421
  }
380
422
  });
@@ -10,6 +10,7 @@ interface Result {
10
10
  fieldProps: any;
11
11
  desensitization: any;
12
12
  valueType: any;
13
+ component: any;
13
14
  }
14
15
  declare const useShouldUpdateForTable: (props: UseShouldUpdateForTableProps) => Result;
15
16
  export default useShouldUpdateForTable;
@@ -8,7 +8,7 @@ import { useRef, useState, useEffect } from 'react';
8
8
  import { isFunction, isEqualWith, debounce } from 'lodash';
9
9
  import { customEqualForFunction } from "../../utils";
10
10
  var useShouldUpdateForTable = props => {
11
- var _isEditableRef$curren, _requiredRef$current, _rulesRef$current, _fieldPropsRef$curren, _desensitizationRef$c, _valueTypeRef$current;
11
+ var _isEditableRef$curren, _requiredRef$current, _rulesRef$current, _fieldPropsRef$curren, _desensitizationRef$c, _valueTypeRef$current, _componentRef$current;
12
12
  var rowParams = props.rowParams,
13
13
  column = props.column,
14
14
  shouldUpdateDebounce = props.shouldUpdateDebounce;
@@ -20,11 +20,13 @@ var useShouldUpdateForTable = props => {
20
20
  var fieldPropsRef = useRef();
21
21
  var desensitizationRef = useRef();
22
22
  var valueTypeRef = useRef();
23
+ var componentRef = useRef();
23
24
  var _useState = useState({}),
24
25
  _useState2 = _slicedToArray(_useState, 2),
25
26
  reRender = _useState2[1];
26
27
  var debouncedUpdateRef = useRef(null);
27
28
  var pendingParamsRef = useRef(null);
29
+ var isInitializedRef = useRef(false);
28
30
 
29
31
  // 统一处理所有动态属性的更新
30
32
  var processUpdate = params => {
@@ -99,6 +101,19 @@ var useShouldUpdateForTable = props => {
99
101
  } else {
100
102
  valueTypeRef.current = column.valueType;
101
103
  }
104
+
105
+ // component 处理(注意:component 是 editRender 的别名)
106
+ var componentOrEditRender = column.component || column.editRender;
107
+ if (isFunction(componentOrEditRender)) {
108
+ var newComponent = componentOrEditRender(values, reactiveParams);
109
+ // 对于 ReactNode 类型的返回值,使用深度比较
110
+ if (!isEqualWith(componentRef.current, newComponent, customEqualForFunction)) {
111
+ componentRef.current = newComponent;
112
+ hasChange = true;
113
+ }
114
+ } else {
115
+ componentRef.current = componentOrEditRender;
116
+ }
102
117
  if (hasChange) {
103
118
  reRender({});
104
119
  }
@@ -106,7 +121,8 @@ var useShouldUpdateForTable = props => {
106
121
 
107
122
  // 创建防抖函数(统一处理所有动态属性)
108
123
  useEffect(() => {
109
- if (shouldUpdateDebounce > 0 && (isFunction(column.isEditable) || isFunction(column.required) || isFunction(column.rules) || isFunction(column.fieldProps) || isFunction(column.desensitization) || isFunction(column.valueType))) {
124
+ var componentOrEditRender = column.component || column.editRender;
125
+ if (shouldUpdateDebounce > 0 && (isFunction(column.isEditable) || isFunction(column.required) || isFunction(column.rules) || isFunction(column.fieldProps) || isFunction(column.desensitization) || isFunction(column.valueType) || isFunction(componentOrEditRender))) {
110
126
  debouncedUpdateRef.current = debounce(() => {
111
127
  if (pendingParamsRef.current) {
112
128
  processUpdate(pendingParamsRef.current);
@@ -121,13 +137,23 @@ var useShouldUpdateForTable = props => {
121
137
  }, [shouldUpdateDebounce, column]);
122
138
 
123
139
  // 统一的属性处理逻辑
124
- if (shouldUpdateDebounce > 0 && debouncedUpdateRef.current) {
125
- // 使用防抖延迟更新
126
- pendingParamsRef.current = rowParams;
127
- debouncedUpdateRef.current();
128
- } else {
129
- // 立即更新(shouldUpdateDebounce = 0 或无防抖函数)
130
- processUpdate(rowParams);
140
+ // 使用 ref 存储上一次的 rowParams,避免引用变化导致的重复调用
141
+ var prevRowParamsRef = useRef(null);
142
+
143
+ // 只有当 rowParams 内容真正变化时才处理更新
144
+ // 或者是第一次初始化
145
+ var shouldProcess = !isInitializedRef.current || !isEqualWith(prevRowParamsRef.current, rowParams, customEqualForFunction);
146
+ if (shouldProcess) {
147
+ prevRowParamsRef.current = rowParams;
148
+ isInitializedRef.current = true;
149
+ if (shouldUpdateDebounce > 0 && debouncedUpdateRef.current) {
150
+ // 使用防抖延迟更新
151
+ pendingParamsRef.current = rowParams;
152
+ debouncedUpdateRef.current();
153
+ } else {
154
+ // 立即更新(shouldUpdateDebounce = 0 或无防抖函数)
155
+ processUpdate(rowParams);
156
+ }
131
157
  }
132
158
  return {
133
159
  isEditable: (_isEditableRef$curren = isEditableRef.current) !== null && _isEditableRef$curren !== void 0 ? _isEditableRef$curren : column.isEditable,
@@ -135,7 +161,8 @@ var useShouldUpdateForTable = props => {
135
161
  rules: (_rulesRef$current = rulesRef.current) !== null && _rulesRef$current !== void 0 ? _rulesRef$current : column.rules,
136
162
  fieldProps: (_fieldPropsRef$curren = fieldPropsRef.current) !== null && _fieldPropsRef$curren !== void 0 ? _fieldPropsRef$curren : column.fieldProps,
137
163
  desensitization: (_desensitizationRef$c = desensitizationRef.current) !== null && _desensitizationRef$c !== void 0 ? _desensitizationRef$c : column.desensitization,
138
- valueType: (_valueTypeRef$current = valueTypeRef.current) !== null && _valueTypeRef$current !== void 0 ? _valueTypeRef$current : column.valueType
164
+ valueType: (_valueTypeRef$current = valueTypeRef.current) !== null && _valueTypeRef$current !== void 0 ? _valueTypeRef$current : column.valueType,
165
+ component: (_componentRef$current = componentRef.current) !== null && _componentRef$current !== void 0 ? _componentRef$current : column.component || column.editRender
139
166
  };
140
167
  };
141
168
  export default useShouldUpdateForTable;
@@ -87,13 +87,7 @@ var DatePicker = props => {
87
87
  restProps.showTime = true;
88
88
  }
89
89
 
90
- // onChange 输出格式化字符串,表单直接存储
91
- var handleChange = (date, dateString) => {
92
- var _rest$onChange;
93
- var valueToStore = date && typeof nextFormat === 'string' ? date.format(nextFormat) : date;
94
- (_rest$onChange = rest.onChange) === null || _rest$onChange === void 0 || _rest$onChange.call(rest, valueToStore, dateString);
95
- };
96
- restProps.onChange = handleChange;
90
+ // 直接透传 onChange,保持 dayjs 对象类型(与 RangePicker 一致)
97
91
 
98
92
  // 字符串时间格式兼容,使用 nextFormat 解析 quarter/week 等格式
99
93
  if (isString(restProps.value)) {
@@ -19,6 +19,22 @@ import { useDateRange } from "./useDateRange";
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  var AntRangePicker = DatePicker.RangePicker;
21
21
 
22
+ /** 与 DatePicker 一致:无 valueType 时按 picker 决定默认展示格式 */
23
+ var getDefaultFormat = picker => {
24
+ switch (picker) {
25
+ case 'week':
26
+ return 'YYYY-ww';
27
+ case 'month':
28
+ return 'YYYY-MM';
29
+ case 'quarter':
30
+ return 'YYYY-[Q]Q';
31
+ case 'year':
32
+ return 'YYYY';
33
+ default:
34
+ return 'YYYY-MM-DD';
35
+ }
36
+ };
37
+
22
38
  // 获取默认快捷选项(presets 格式)
23
39
  var getDefaultPresets = () => {
24
40
  var _locale$RangePicker;
@@ -47,8 +63,7 @@ var getDefaultPresets = () => {
47
63
  }];
48
64
  };
49
65
  var RangePicker = props => {
50
- var _props$format = props.format,
51
- format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format,
66
+ var format = props.format,
52
67
  otherProps = props.otherProps,
53
68
  _props$separator = props.separator,
54
69
  separator = _props$separator === void 0 ? '~' : _props$separator,
@@ -61,6 +76,22 @@ var RangePicker = props => {
61
76
  viewEmpty = _ref.viewEmpty,
62
77
  valueType = _ref.valueType;
63
78
 
79
+ // 优先级:valueType > format > picker 默认(与 DatePicker 一致)
80
+ var nextFormat;
81
+ if (valueType === 'dateTime') {
82
+ nextFormat = 'YYYY-MM-DD HH:mm:ss';
83
+ } else if (valueType === 'date' || valueType === 'dateStartEndTime') {
84
+ nextFormat = 'YYYY-MM-DD';
85
+ } else if (isFunction(format)) {
86
+ nextFormat = undefined;
87
+ } else if (Array.isArray(format) && format.length && !isFunction(format[0])) {
88
+ nextFormat = format[0];
89
+ } else if (typeof format === 'string') {
90
+ nextFormat = format;
91
+ } else {
92
+ nextFormat = getDefaultFormat(rest.picker);
93
+ }
94
+
64
95
  // 返回函数管理起止时间可选范围
65
96
  var rangeRegulator = useDateRange({
66
97
  range,
@@ -89,16 +120,35 @@ var RangePicker = props => {
89
120
  }
90
121
  }
91
122
 
92
- // 字符串时间格式兼容
123
+ // 字符串时间格式兼容(与 DatePicker 一致:优先按 nextFormat 严格解析)
93
124
  if (Array.isArray(_rest.value) && isString(_rest.value[0]) && isString(_rest.value[1])) {
94
- _rest.value = [dayjs(_rest.value[0]), dayjs(_rest.value[1])];
125
+ var parseRangeString = s => {
126
+ if (nextFormat && !isFunction(format)) {
127
+ var parsed = dayjs(s, nextFormat, true);
128
+ if (parsed.isValid()) return parsed;
129
+ }
130
+ return dayjs(s);
131
+ };
132
+ _rest.value = [parseRangeString(_rest.value[0]), parseRangeString(_rest.value[1])];
95
133
  }
96
- var _viewFormat = Array.isArray(format) ? format[0] : format;
97
- var tempFormat = Array.isArray(format) ? format : [format];
134
+ var tempFormat;
98
135
  if (isFunction(format)) {
99
136
  tempFormat = [];
137
+ } else if (valueType === 'dateTime') {
138
+ tempFormat = ['YYYY-MM-DD HH:mm:ss'];
139
+ } else if (valueType === 'date' || valueType === 'dateStartEndTime') {
140
+ tempFormat = ['YYYY-MM-DD'];
141
+ } else if (Array.isArray(format)) {
142
+ tempFormat = format.filter(f => typeof f === 'string') || [];
143
+ if (!tempFormat.length) {
144
+ tempFormat = [getDefaultFormat(rest.picker)];
145
+ }
146
+ } else if (typeof format === 'string') {
147
+ tempFormat = [format];
148
+ } else {
149
+ tempFormat = [getDefaultFormat(rest.picker)];
100
150
  }
101
- var _format = uniq([...tempFormat, 'YYYY-MM-DD', 'YYYYMMDD', 'YYYY/MM/DD', 'YYYY_MM_DD', 'YYYY.MM.DD']).filter(formatKey => !!formatKey);
151
+ var _format = uniq([...tempFormat, 'YYYY-MM-DD HH:mm:ss', 'YYYY-MM-DD', 'YYYYMMDD', 'YYYY/MM/DD', 'YYYY_MM_DD', 'YYYY.MM.DD']).filter(formatKey => !!formatKey);
102
152
  var _defaultShowTime = {
103
153
  format: 'HH:mm:ss'
104
154
  };
@@ -108,6 +158,9 @@ var RangePicker = props => {
108
158
  var viewChildren = null;
109
159
  if (!value || !value[0] || !value[1]) {
110
160
  viewChildren = null;
161
+ } else if (valueType === 'dateTime' || valueType === 'date' || valueType === 'dateStartEndTime') {
162
+ var vf = nextFormat || 'YYYY-MM-DD';
163
+ viewChildren = `${value[0].format(vf)} ${separator} ${value[1].format(vf)}`;
111
164
  } else if (Array.isArray(format)) {
112
165
  var formattedList = format.map((formatItem, index) => {
113
166
  var _format2, _ref2;
@@ -120,7 +173,8 @@ var RangePicker = props => {
120
173
  } else if (isFunction(format)) {
121
174
  viewChildren = `${format(value[0])} ${separator} ${format(value[1])}`;
122
175
  } else {
123
- viewChildren = `${value[0].format(_viewFormat)} ${separator} ${value[1].format(_viewFormat)}`;
176
+ var _vf = (typeof format === 'string' ? format : nextFormat) || 'YYYY-MM-DD';
177
+ viewChildren = `${value[0].format(_vf)} ${separator} ${value[1].format(_vf)}`;
124
178
  }
125
179
  return /*#__PURE__*/_jsx(Container, {
126
180
  viewEmpty: viewEmpty,
@@ -20,6 +20,8 @@ interface Props {
20
20
  formItemClassName?: string;
21
21
  formItemStyle?: React.CSSProperties;
22
22
  dependencies?: NamePath[];
23
+ required?: boolean;
24
+ rules?: any[];
23
25
  }
24
26
  /** 渲染组件 */
25
27
  declare const ComRender: React.FC<Props>;
@@ -89,6 +89,16 @@ var ComRender = props => {
89
89
  // 传统模式 compact 模式:需要 Form.Item 包装并应用宽度样式
90
90
  // 通过 formItemClassName 和 formItemStyle 来判断是否需要 Form.Item 包装
91
91
  if (formItemClassName && name) {
92
+ // 从 rest 中提取 required 和 rules,在非编辑态时移除校验
93
+ var formItemProps = _objectSpread({
94
+ name,
95
+ className: formItemClassName,
96
+ style: formItemStyle
97
+ }, isView ? {} : {
98
+ required: rest === null || rest === void 0 ? void 0 : rest.required,
99
+ rules: rest === null || rest === void 0 ? void 0 : rest.rules
100
+ });
101
+
92
102
  // 如果有依赖字段,使用 shouldUpdate 来实时更新错误状态
93
103
  if (dependencies && dependencies.length > 0) {
94
104
  return /*#__PURE__*/_jsx(Form.Item, {
@@ -102,7 +112,7 @@ var ComRender = props => {
102
112
  });
103
113
  var hasChanged = currentFieldChanged || dependenciesChanged;
104
114
  // 当检测到变化时,触发字段校验以更新错误状态
105
- if (hasChanged && contextProps !== null && contextProps !== void 0 && contextProps.form && name) {
115
+ if (hasChanged && contextProps !== null && contextProps !== void 0 && contextProps.form && name && !isView) {
106
116
  setTimeout(() => {
107
117
  contextProps.form.validateFields([name]).catch(() => {});
108
118
  }, 0);
@@ -110,10 +120,7 @@ var ComRender = props => {
110
120
  return hasChanged;
111
121
  },
112
122
  noStyle: true,
113
- children: () => /*#__PURE__*/_jsx(Form.Item, {
114
- name: name,
115
- className: formItemClassName,
116
- style: formItemStyle,
123
+ children: () => /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemProps), {}, {
117
124
  children: /*#__PURE__*/_jsx(FieldProvider, {
118
125
  value: _objectSpread(_objectSpread({}, contextProps), {}, {
119
126
  valueType,
@@ -122,14 +129,11 @@ var ComRender = props => {
122
129
  }),
123
130
  children: renderComponent
124
131
  })
125
- })
132
+ }))
126
133
  });
127
134
  }
128
135
  // 没有依赖字段,直接渲染 Form.Item
129
- return /*#__PURE__*/_jsx(Form.Item, {
130
- name: name,
131
- className: formItemClassName,
132
- style: formItemStyle,
136
+ return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread({}, formItemProps), {}, {
133
137
  children: /*#__PURE__*/_jsx(FieldProvider, {
134
138
  value: _objectSpread(_objectSpread({}, contextProps), {}, {
135
139
  valueType,
@@ -138,7 +142,7 @@ var ComRender = props => {
138
142
  }),
139
143
  children: renderComponent
140
144
  })
141
- });
145
+ }));
142
146
  }
143
147
 
144
148
  // 非传统模式 compact 模式:直接渲染组件
@@ -118,16 +118,16 @@ var FlexibleGroupRender = props => {
118
118
  var childDisabled = typeof child.disabled === 'function' ? false : child.disabled;
119
119
  var finalDisabled = groupDisabled || childDisabled;
120
120
 
121
- // 构建 formItemProps
121
+ // 构建 formItemProps - 在非编辑态时移除校验规则
122
122
  var formItemProps = {
123
123
  name: fullName,
124
124
  label: child.label,
125
- rules: child.rules,
125
+ rules: isView ? undefined : child.rules,
126
126
  dependencies: processedDependencies,
127
127
  extra: child.extra,
128
128
  before: child.before,
129
129
  after: child.after,
130
- required: child.required,
130
+ required: isView ? undefined : child.required,
131
131
  disabled: finalDisabled,
132
132
  validateFirst: child.validateFirst
133
133
  };
@@ -148,13 +148,40 @@ var FlexibleGroupRender = props => {
148
148
  formItemProps.tooltip = child.tooltip;
149
149
  }
150
150
 
151
+ // 在ProEditTable场景下,如果同组其他字段有值,则当前字段空值不显示 -
152
+ var childViewEmpty = otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty;
153
+ if (isView && (otherProps === null || otherProps === void 0 ? void 0 : otherProps.source) === 'ProEditTable' && form && children.length > 1) {
154
+ // 检查同组其他字段是否有值
155
+ var hasOtherValues = children.some(otherChild => {
156
+ if (otherChild === child) return false; // 跳过当前字段
157
+
158
+ var otherChildNamePath = otherChild.namePath || contextProps.namePath;
159
+ var otherFullName = (() => {
160
+ if (otherChildNamePath && Array.isArray(otherChild.name) && otherChild.name.length > 1) {
161
+ return [...otherChildNamePath, ...otherChild.name];
162
+ }
163
+ if (otherChildNamePath) {
164
+ return [...otherChildNamePath, otherChild.name];
165
+ }
166
+ return otherChild.name;
167
+ })();
168
+ var value = form.getFieldValue(otherFullName);
169
+ return value !== undefined && value !== null && value !== '';
170
+ });
171
+
172
+ // 如果有其他字段有值,当前字段空值显示为空字符串
173
+ if (hasOtherValues) {
174
+ childViewEmpty = '';
175
+ }
176
+ }
177
+
151
178
  // 构建 otherProps
152
179
  var renderOtherProps = {
153
180
  label: child.label,
154
181
  name: fullName,
155
182
  disabled: finalDisabled,
156
183
  isView,
157
- viewEmpty: otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty,
184
+ viewEmpty: childViewEmpty,
158
185
  valueType: child.valueType,
159
186
  form,
160
187
  type,
@@ -268,12 +295,16 @@ var FlexibleGroupRender = props => {
268
295
  elements.push(formElement);
269
296
 
270
297
  // 添加分隔符
271
- if (index < visibleChildren.length - 1 && space !== null && space !== void 0 && space.separator) {
298
+ // 查看模式下,如果没有配置separator,使用默认的 finalSeparator
299
+ var separatorToUse = isView ? (space === null || space === void 0 ? void 0 : space.separator) || finalSeparator : space === null || space === void 0 ? void 0 : space.separator;
300
+ if (index < visibleChildren.length - 1 && separatorToUse) {
272
301
  var shouldAddSeparator = space.separatorIndex ? Array.isArray(space.separatorIndex) ? space.separatorIndex.includes(originalIndex) : space.separatorIndex === originalIndex : true;
273
302
  if (shouldAddSeparator) {
303
+ // 查看模式下使用不同的className,避免显示边框
304
+ var separatorClassName = isView ? 'pro-group-separator-compact pro-group-separator-view' : 'pro-group-separator-compact';
274
305
  elements.push( /*#__PURE__*/_jsx("span", {
275
- className: "pro-group-separator-compact",
276
- children: space.separator
306
+ className: separatorClassName,
307
+ children: separatorToUse
277
308
  }, child.name ? `separator-${child.name}` : `separator-${originalIndex}`));
278
309
  }
279
310
  }
@@ -303,6 +334,29 @@ var FlexibleGroupRender = props => {
303
334
  return (otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty) || '-';
304
335
  }
305
336
 
337
+ // 查看模式下,检查所有children的值是否都为空
338
+ if (isView && form && children.length > 0) {
339
+ var allValuesEmpty = children.every(child => {
340
+ var childNamePath = child.namePath || contextProps.namePath;
341
+ var fullName = (() => {
342
+ if (childNamePath && Array.isArray(child.name) && child.name.length > 1) {
343
+ return [...childNamePath, ...child.name];
344
+ }
345
+ if (childNamePath) {
346
+ return [...childNamePath, child.name];
347
+ }
348
+ return child.name;
349
+ })();
350
+ var value = form.getFieldValue(fullName);
351
+ return value === undefined || value === null || value === '';
352
+ });
353
+
354
+ // 如果所有值都为空,显示一个 -
355
+ if (allValuesEmpty) {
356
+ return (otherProps === null || otherProps === void 0 ? void 0 : otherProps.viewEmpty) || '-';
357
+ }
358
+ }
359
+
306
360
  // 渲染内容
307
361
  var renderContent = () => {
308
362
  return /*#__PURE__*/_jsx("div", {