@zat-design/sisyphus-react 4.1.2-beta.2 → 4.1.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/ProEditTable/components/RenderField/index.js +39 -14
- package/es/ProEditTable/utils/index.js +26 -19
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +18 -7
- package/es/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/es/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/es/ProForm/components/combination/Group/style/index.less +26 -1
- package/es/ProForm/components/combination/Group/utils/index.d.ts +19 -19
- package/es/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/es/ProForm/propsType.d.ts +3 -3
- package/es/ProForm/utils/transformValue.d.ts +1 -1
- package/es/ProForm/utils/useForm.d.ts +1 -1
- package/es/ProForm/utils/useWatch.d.ts +2 -1
- package/es/ProForm/utils/useWatch.js +3 -1
- package/es/ProUpload/propsType.d.ts +1 -1
- package/lib/ProEditTable/components/RenderField/index.js +39 -14
- package/lib/ProEditTable/utils/index.js +26 -19
- package/lib/ProEditTable/utils/useShouldUpdateForTable.js +18 -7
- package/lib/ProForm/components/combination/Group/component/ComRender.d.ts +2 -0
- package/lib/ProForm/components/combination/Group/component/ComRender.js +15 -11
- package/lib/ProForm/components/combination/Group/component/FlexibleGroup.js +61 -7
- package/lib/ProForm/components/combination/Group/style/index.less +26 -1
- package/lib/ProForm/components/combination/Group/utils/index.d.ts +19 -19
- package/lib/ProForm/components/combination/ProCascader/propsType.d.ts +1 -1
- package/lib/ProForm/propsType.d.ts +3 -3
- package/lib/ProForm/utils/transformValue.d.ts +1 -1
- package/lib/ProForm/utils/useForm.d.ts +1 -1
- package/lib/ProForm/utils/useWatch.d.ts +2 -1
- package/lib/ProForm/utils/useWatch.js +3 -1
- package/lib/ProUpload/propsType.d.ts +1 -1
- package/package.json +1 -1
|
@@ -208,7 +208,7 @@ var RenderField = _ref => {
|
|
|
208
208
|
label: label,
|
|
209
209
|
labelRequired,
|
|
210
210
|
required: !isView && _required,
|
|
211
|
-
rules:
|
|
211
|
+
rules: !isView ? _rules : [],
|
|
212
212
|
isSelect: isSelect({
|
|
213
213
|
dataSource: (_fieldProps2 = _fieldProps) === null || _fieldProps2 === void 0 ? void 0 : _fieldProps2.dataSource,
|
|
214
214
|
type
|
|
@@ -709,18 +709,35 @@ var RenderField = _ref => {
|
|
|
709
709
|
if (shouldUpdateMode) {
|
|
710
710
|
// 重新获取最新的行数据
|
|
711
711
|
var latestRowData = form.getFieldValue([...namePath, index]) || record || {};
|
|
712
|
-
var
|
|
713
|
-
index,
|
|
712
|
+
var latestReactiveParams = {
|
|
714
713
|
form,
|
|
715
|
-
|
|
714
|
+
index,
|
|
716
715
|
namePath: [...namePath, index]
|
|
717
716
|
};
|
|
718
|
-
var latestRowParams = [latestRowData,
|
|
717
|
+
var latestRowParams = [latestRowData, latestReactiveParams];
|
|
719
718
|
|
|
720
|
-
//
|
|
719
|
+
// ⭐ 关键修改:shouldUpdate 模式下,跳过缓存,直接重新计算所有响应式属性
|
|
721
720
|
var latestFieldProps = fieldProps || formItemProps || {};
|
|
722
721
|
if (isFunction(fieldProps)) {
|
|
723
|
-
latestFieldProps = fieldProps(
|
|
722
|
+
latestFieldProps = fieldProps(latestRowData, latestReactiveParams);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// 重新计算 required(用于可能的后续逻辑)
|
|
726
|
+
var latestRequired = required;
|
|
727
|
+
if (isFunction(required)) {
|
|
728
|
+
latestRequired = required(latestRowData, latestReactiveParams);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// 重新计算 rules(用于可能的后续逻辑)
|
|
732
|
+
var latestRules = rules;
|
|
733
|
+
if (isFunction(rules)) {
|
|
734
|
+
latestRules = rules(latestRowData, latestReactiveParams);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// 重新计算 desensitization
|
|
738
|
+
var latestDesensitization = desensitization || [];
|
|
739
|
+
if (isFunction(desensitization)) {
|
|
740
|
+
latestDesensitization = desensitization(latestRowData, latestReactiveParams);
|
|
724
741
|
}
|
|
725
742
|
|
|
726
743
|
// 重新计算 disabled
|
|
@@ -733,10 +750,12 @@ var RenderField = _ref => {
|
|
|
733
750
|
params: latestRowParams
|
|
734
751
|
});
|
|
735
752
|
|
|
736
|
-
// 更新 componentProps
|
|
737
|
-
finalComponentProps = _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
753
|
+
// 更新 componentProps 中的所有响应式属性
|
|
754
|
+
finalComponentProps = _objectSpread(_objectSpread(_objectSpread({}, componentProps), {}, {
|
|
738
755
|
disabled: latestDisabled
|
|
739
|
-
}, latestFieldProps)
|
|
756
|
+
}, latestFieldProps), {}, {
|
|
757
|
+
desensitization: latestDesensitization
|
|
758
|
+
});
|
|
740
759
|
}
|
|
741
760
|
var FormItem = null;
|
|
742
761
|
// 当 viewRender 存在时,需要排除 finalComponentProps 中的 children,避免覆盖 Container 的 children
|
|
@@ -843,20 +862,26 @@ export default /*#__PURE__*/memo(RenderField, (prevProps, nextProps) => {
|
|
|
843
862
|
}
|
|
844
863
|
|
|
845
864
|
// fieldProps 函数化直接更新,无法比对返回值是否一致
|
|
865
|
+
// 优化:不直接调用函数,而是比较输入参数(record 和 reactiveParams)
|
|
866
|
+
// 如果输入参数相同,fieldProps 的返回值应该相同(纯函数假设)
|
|
846
867
|
if (isFunction(prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn.fieldProps) && isFunction(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.fieldProps)) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (!isEqualWith(prevFieldProps, nextFieldProps, customEqualForFunction)) {
|
|
868
|
+
// 比较 record 数据是否变化
|
|
869
|
+
if (!isEqualWith(prevRecord, nextRecord, customEqualForFunction)) {
|
|
850
870
|
return false;
|
|
851
871
|
}
|
|
872
|
+
// reactiveParams 中的 form、index、namePath 已经在外层比较过了,无需重复比较
|
|
852
873
|
}
|
|
853
874
|
|
|
854
875
|
// 通用函数比较方法
|
|
876
|
+
// 优化:不直接调用函数,而是比较输入参数
|
|
877
|
+
// 对于纯函数,如果输入相同则输出相同
|
|
855
878
|
var compareFunctionResult = (prevColumn, nextColumn, prevValues, nextValues, prevReactiveParams, nextReactiveParams, functionName) => {
|
|
856
879
|
var prevFunc = prevColumn === null || prevColumn === void 0 ? void 0 : prevColumn[functionName];
|
|
857
880
|
var nextFunc = nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn[functionName];
|
|
858
881
|
if (isFunction(prevFunc) && isFunction(nextFunc)) {
|
|
859
|
-
|
|
882
|
+
// 比较输入参数而不是调用函数
|
|
883
|
+
// 如果 values 相同,则函数结果应该相同(纯函数假设)
|
|
884
|
+
return isEqualWith(prevValues, nextValues, customEqualForFunction);
|
|
860
885
|
}
|
|
861
886
|
return true; // 如果不是函数或只有一个是函数,认为相等
|
|
862
887
|
};
|
|
@@ -41,7 +41,8 @@ var getActionColumn = config => {
|
|
|
41
41
|
actionProps = _cloneDeepWith.actionProps,
|
|
42
42
|
page = _cloneDeepWith.page,
|
|
43
43
|
rowDisabled = _cloneDeepWith.rowDisabled,
|
|
44
|
-
actionDirection = _cloneDeepWith.actionDirection
|
|
44
|
+
actionDirection = _cloneDeepWith.actionDirection,
|
|
45
|
+
editingKeys = _cloneDeepWith.editingKeys;
|
|
45
46
|
var pageNum = tools.calc(page.pageNum, '-', 1);
|
|
46
47
|
var firstIndex = tools.calc(pageNum, '*', page.pageSize);
|
|
47
48
|
// actionProps配置为false 默认不插入
|
|
@@ -89,7 +90,7 @@ var getActionColumn = config => {
|
|
|
89
90
|
action.onEvent = /*#__PURE__*/function () {
|
|
90
91
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(record, _ref) {
|
|
91
92
|
var _form$getFieldValue;
|
|
92
|
-
var index, form, name, namePath, tableLength, selectedRows, rowName, lastRecord, onEvent, result, actionHandler;
|
|
93
|
+
var index, form, name, namePath, tableLength, selectedRows, rowName, _isEditing, lastRecord, onEvent, result, actionHandler;
|
|
93
94
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
94
95
|
while (1) switch (_context.prev = _context.next) {
|
|
95
96
|
case 0:
|
|
@@ -97,33 +98,39 @@ var getActionColumn = config => {
|
|
|
97
98
|
index = tools.calc(firstIndex, '+', index);
|
|
98
99
|
rowName = [...virtualRowName, index];
|
|
99
100
|
if (!(type === 'save')) {
|
|
100
|
-
_context.next =
|
|
101
|
+
_context.next = 15;
|
|
101
102
|
break;
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
// 判断该行是否处于编辑状态
|
|
105
|
+
_isEditing = !virtualKey || editingKeys.includes(record.rowKey) || record._addFlag; // 只有编辑中的行才需要校验
|
|
106
|
+
if (!_isEditing) {
|
|
107
|
+
_context.next = 15;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
_context.prev = 6;
|
|
111
|
+
_context.next = 9;
|
|
105
112
|
return customValidate(validateKeys, form, rowName);
|
|
106
|
-
case 7:
|
|
107
|
-
_context.next = 13;
|
|
108
|
-
break;
|
|
109
113
|
case 9:
|
|
110
|
-
_context.
|
|
111
|
-
|
|
114
|
+
_context.next = 15;
|
|
115
|
+
break;
|
|
116
|
+
case 11:
|
|
117
|
+
_context.prev = 11;
|
|
118
|
+
_context.t0 = _context["catch"](6);
|
|
112
119
|
handleScrollToError();
|
|
113
120
|
return _context.abrupt("return", Promise.reject(_context.t0));
|
|
114
|
-
case
|
|
121
|
+
case 15:
|
|
115
122
|
// 编辑状态使用自定义form值,非编辑状态直接使用行数据
|
|
116
123
|
lastRecord = filterInternalFields((_form$getFieldValue = form.getFieldValue(rowName)) !== null && _form$getFieldValue !== void 0 ? _form$getFieldValue : record); // 新增事件可以设置初始默认值,当做函数的出参导出
|
|
117
124
|
onEvent = onClick || onHandle;
|
|
118
125
|
if (onEvent) {
|
|
119
|
-
_context.next =
|
|
126
|
+
_context.next = 21;
|
|
120
127
|
break;
|
|
121
128
|
}
|
|
122
129
|
result = true;
|
|
123
|
-
_context.next =
|
|
130
|
+
_context.next = 24;
|
|
124
131
|
break;
|
|
125
|
-
case
|
|
126
|
-
_context.next =
|
|
132
|
+
case 21:
|
|
133
|
+
_context.next = 23;
|
|
127
134
|
return onEvent === null || onEvent === void 0 ? void 0 : onEvent(lastRecord, {
|
|
128
135
|
form,
|
|
129
136
|
index,
|
|
@@ -132,9 +139,9 @@ var getActionColumn = config => {
|
|
|
132
139
|
namePath,
|
|
133
140
|
selectedRows
|
|
134
141
|
});
|
|
135
|
-
case
|
|
142
|
+
case 23:
|
|
136
143
|
result = _context.sent;
|
|
137
|
-
case
|
|
144
|
+
case 24:
|
|
138
145
|
if (result !== false && type !== 'custom') {
|
|
139
146
|
actionHandler = actions[type];
|
|
140
147
|
actionHandler(_objectSpread(_objectSpread({}, config), {}, {
|
|
@@ -145,11 +152,11 @@ var getActionColumn = config => {
|
|
|
145
152
|
validateKeys
|
|
146
153
|
}));
|
|
147
154
|
}
|
|
148
|
-
case
|
|
155
|
+
case 25:
|
|
149
156
|
case "end":
|
|
150
157
|
return _context.stop();
|
|
151
158
|
}
|
|
152
|
-
}, _callee, null, [[
|
|
159
|
+
}, _callee, null, [[6, 11]]);
|
|
153
160
|
}));
|
|
154
161
|
return function (_x, _x2) {
|
|
155
162
|
return _ref2.apply(this, arguments);
|
|
@@ -25,6 +25,7 @@ var useShouldUpdateForTable = props => {
|
|
|
25
25
|
reRender = _useState2[1];
|
|
26
26
|
var debouncedUpdateRef = useRef(null);
|
|
27
27
|
var pendingParamsRef = useRef(null);
|
|
28
|
+
var isInitializedRef = useRef(false);
|
|
28
29
|
|
|
29
30
|
// 统一处理所有动态属性的更新
|
|
30
31
|
var processUpdate = params => {
|
|
@@ -121,13 +122,23 @@ var useShouldUpdateForTable = props => {
|
|
|
121
122
|
}, [shouldUpdateDebounce, column]);
|
|
122
123
|
|
|
123
124
|
// 统一的属性处理逻辑
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
// 使用 ref 存储上一次的 rowParams,避免引用变化导致的重复调用
|
|
126
|
+
var prevRowParamsRef = useRef(null);
|
|
127
|
+
|
|
128
|
+
// 只有当 rowParams 内容真正变化时才处理更新
|
|
129
|
+
// 或者是第一次初始化
|
|
130
|
+
var shouldProcess = !isInitializedRef.current || !isEqualWith(prevRowParamsRef.current, rowParams, customEqualForFunction);
|
|
131
|
+
if (shouldProcess) {
|
|
132
|
+
prevRowParamsRef.current = rowParams;
|
|
133
|
+
isInitializedRef.current = true;
|
|
134
|
+
if (shouldUpdateDebounce > 0 && debouncedUpdateRef.current) {
|
|
135
|
+
// 使用防抖延迟更新
|
|
136
|
+
pendingParamsRef.current = rowParams;
|
|
137
|
+
debouncedUpdateRef.current();
|
|
138
|
+
} else {
|
|
139
|
+
// 立即更新(shouldUpdateDebounce = 0 或无防抖函数)
|
|
140
|
+
processUpdate(rowParams);
|
|
141
|
+
}
|
|
131
142
|
}
|
|
132
143
|
return {
|
|
133
144
|
isEditable: (_isEditableRef$curren = isEditableRef.current) !== null && _isEditableRef$curren !== void 0 ? _isEditableRef$curren : column.isEditable,
|
|
@@ -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:
|
|
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
|
-
|
|
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:
|
|
276
|
-
children:
|
|
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", {
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
width: unset !important;
|
|
6
6
|
|
|
7
|
+
&.pro-group-view {
|
|
8
|
+
.pro-group-form-item {
|
|
9
|
+
flex: 0 0 auto !important;
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
.@{ant-prefix}-space-compact .pro-group-separator-compact{
|
|
13
|
+
color: #333 !important;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
|
|
9
18
|
&.pro-group-view {
|
|
@@ -385,6 +394,13 @@
|
|
|
385
394
|
// margin: 0 !important;
|
|
386
395
|
}
|
|
387
396
|
|
|
397
|
+
// 查看模式下,Form.Item不平分空间,而是根据内容自适应
|
|
398
|
+
&.pro-group-view {
|
|
399
|
+
.pro-group-form-item {
|
|
400
|
+
flex: 0 0 auto;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
388
404
|
// 当有自定义宽度时,只有设置了宽度的 Form.Item 不使用 flex:1
|
|
389
405
|
&.pro-group-diy-width {
|
|
390
406
|
// 覆盖 Space.Compact 内设置了宽度的 Form.Item
|
|
@@ -430,7 +446,7 @@
|
|
|
430
446
|
}
|
|
431
447
|
|
|
432
448
|
.@{ant-prefix}-input-number-input {
|
|
433
|
-
border-left:
|
|
449
|
+
border-left: 0 !important;
|
|
434
450
|
}
|
|
435
451
|
}
|
|
436
452
|
|
|
@@ -467,6 +483,15 @@
|
|
|
467
483
|
margin-left: -1px;
|
|
468
484
|
}
|
|
469
485
|
|
|
486
|
+
// 查看模式下的分隔符样式 - 移除边框,使用简洁样式
|
|
487
|
+
.pro-group-separator-view {
|
|
488
|
+
border: none !important;
|
|
489
|
+
background: transparent !important;
|
|
490
|
+
padding: 0 2px !important;
|
|
491
|
+
margin-inline-start: 0 !important;
|
|
492
|
+
color: #999 !important;
|
|
493
|
+
}
|
|
494
|
+
|
|
470
495
|
|
|
471
496
|
/* 1. 处理第一个子元素:左上、左下圆角 */
|
|
472
497
|
> .pro-group-form-item:first-child{
|
|
@@ -75,21 +75,13 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
75
75
|
confirm?: boolean | import("antd").ModalFuncProps | import("../../../render/propsType").FunctionArgs<any, boolean | import("antd").ModalFuncProps>;
|
|
76
76
|
show?: boolean | ReactiveFunction<any, boolean>;
|
|
77
77
|
component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
|
|
78
|
-
|
|
79
|
-
className?: string;
|
|
80
|
-
hidden?: boolean;
|
|
81
|
-
style?: React.CSSProperties;
|
|
82
|
-
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
83
|
-
onReset?: () => void;
|
|
84
|
-
prefixCls?: string;
|
|
85
|
-
status?: "" | "warning" | "error" | "success" | "validating";
|
|
86
|
-
rootClassName?: string;
|
|
87
|
-
isView?: boolean;
|
|
78
|
+
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
88
79
|
colon?: boolean;
|
|
89
80
|
htmlFor?: string;
|
|
90
81
|
labelAlign?: import("antd/es/form/interface").FormLabelAlign;
|
|
91
82
|
labelCol?: import("antd").ColProps;
|
|
92
83
|
vertical?: boolean;
|
|
84
|
+
children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
|
|
93
85
|
getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
|
|
94
86
|
normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
|
|
95
87
|
shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
|
|
@@ -97,36 +89,44 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
97
89
|
validateTrigger?: string | false | string[];
|
|
98
90
|
validateDebounce?: number;
|
|
99
91
|
valuePropName?: string;
|
|
100
|
-
getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
|
|
101
92
|
messageVariables?: Record<string, string>;
|
|
102
93
|
initialValue?: any;
|
|
94
|
+
onReset?: () => void;
|
|
103
95
|
onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
|
|
104
96
|
preserve?: boolean;
|
|
105
97
|
isListField?: boolean;
|
|
106
98
|
isList?: boolean;
|
|
99
|
+
prefixCls?: string;
|
|
107
100
|
noStyle?: boolean;
|
|
101
|
+
style?: React.CSSProperties;
|
|
102
|
+
className?: string;
|
|
103
|
+
rootClassName?: string;
|
|
104
|
+
id?: string;
|
|
108
105
|
hasFeedback?: boolean | {
|
|
109
106
|
icons: import("antd/es/form/FormItem").FeedbackIcons;
|
|
110
107
|
};
|
|
111
|
-
validateStatus?: "" | "
|
|
108
|
+
validateStatus?: "" | "success" | "warning" | "error" | "validating";
|
|
109
|
+
hidden?: boolean;
|
|
112
110
|
layout?: import("antd/es/form/Form").FormItemLayout;
|
|
113
111
|
wrapperCol?: import("antd").ColProps;
|
|
112
|
+
status?: "" | "success" | "warning" | "error" | "validating";
|
|
114
113
|
help?: React.ReactNode;
|
|
115
114
|
fieldId?: string;
|
|
116
|
-
|
|
115
|
+
toISOString?: boolean;
|
|
116
|
+
toCSTString?: boolean;
|
|
117
117
|
switchValue?: [any, any];
|
|
118
|
+
clearNotShow?: boolean;
|
|
119
|
+
valueType?: import("../../../render/propsType").ProFormValueType;
|
|
118
120
|
viewRender?: (value: any, record: any, { form, index, namePath, }: {
|
|
119
121
|
[key: string]: any;
|
|
120
122
|
form: FormInstance<any>;
|
|
121
123
|
index?: number;
|
|
122
124
|
}) => string | React.ReactElement<any, any>;
|
|
123
|
-
viewType?: import("../../../render/propsType").ViewType;
|
|
124
125
|
trim?: boolean;
|
|
125
|
-
upperCase?: boolean;
|
|
126
|
-
toISOString?: boolean;
|
|
127
|
-
toCSTString?: boolean;
|
|
128
|
-
clearNotShow?: boolean;
|
|
129
126
|
desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
|
|
127
|
+
isView?: boolean;
|
|
128
|
+
upperCase?: boolean;
|
|
129
|
+
viewType?: import("../../../render/propsType").ViewType;
|
|
130
130
|
name: any;
|
|
131
131
|
dependencies: any[];
|
|
132
132
|
tooltip: string | {
|
|
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
|
|
|
141
141
|
* 创建组件属性
|
|
142
142
|
*/
|
|
143
143
|
export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
|
|
144
|
-
componentProps: import("lodash").Omit<any, "format" | "
|
|
144
|
+
componentProps: import("lodash").Omit<any, "format" | "toISOString" | "toCSTString" | "switchValue" | "precision" | "clearNotShow" | "dependNames" | "valueType">;
|
|
145
145
|
formItemTransform: {
|
|
146
146
|
getValueProps: any;
|
|
147
147
|
normalize: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { DefaultOptionType } from 'rc-select/
|
|
2
|
+
import { DefaultOptionType } from '@rc-component/select/es/Select';
|
|
3
3
|
import { Service, Options } from 'ahooks/lib/useRequest/src/types';
|
|
4
4
|
export interface FieldNamesType {
|
|
5
5
|
label: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
1
2
|
import { ButtonProps, ColProps, RowProps } from 'antd';
|
|
2
3
|
import { FormProps, FormInstance } from 'antd/es/form/Form';
|
|
3
4
|
import { NamePath } from 'antd/es/form/interface';
|
|
4
|
-
import { StoreValue, Store } from 'rc-
|
|
5
|
-
import { ShouldUpdate } from 'rc-
|
|
6
|
-
import React, { ReactNode } from 'react';
|
|
5
|
+
import type { StoreValue, Store } from '@rc-component/form/es/interface';
|
|
6
|
+
import type { ShouldUpdate } from '@rc-component/form/es/Field';
|
|
7
7
|
import type { ProFormColumnType, ViewType } from './components/render/propsType';
|
|
8
8
|
import type { ProFormComponentType } from './components';
|
|
9
9
|
export interface ButtonType extends ButtonProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormInstance, FormItemProps } from 'antd';
|
|
2
2
|
import { NamePath } from 'antd/es/form/interface';
|
|
3
|
-
import { StoreValue, Store } from 'rc-
|
|
3
|
+
import type { StoreValue, Store } from '@rc-component/form/es/interface';
|
|
4
4
|
import type { TransformType } from '../propsType';
|
|
5
5
|
export declare const transformValue: (names: NamePath[], form: FormInstance, fieldName: NamePath, normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue, getValueProps?: FormItemProps['getValueProps']) => TransformType;
|
|
6
6
|
export default transformValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormInstance } from 'antd';
|
|
2
2
|
import { NamePath } from 'antd/es/form/interface';
|
|
3
|
-
import { ValuedNotifyInfo } from 'rc-
|
|
3
|
+
import type { ValuedNotifyInfo } from '@rc-component/form/es/interface';
|
|
4
4
|
export type ModifiedFormInstanceType<T> = FormInstance<T> & {
|
|
5
5
|
isModified?: boolean;
|
|
6
6
|
/** 默认清空设置值的报错状态 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FormInstance
|
|
1
|
+
import { FormInstance } from 'antd/es/form/Form';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
2
3
|
export declare function toArray<T>(value?: T | T[] | null): T[];
|
|
3
4
|
/**
|
|
4
5
|
* ProForm的useWatch hook,用于监听表单字段变化
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UploadFile } from 'antd/es/upload/interface';
|
|
3
|
-
import { UploadRequestOption } from 'rc-upload/
|
|
3
|
+
import type { UploadRequestOption } from '@rc-component/upload/es/interface';
|
|
4
4
|
export type UploadType = 'drag' | 'button' | 'image';
|
|
5
5
|
export interface UploadFileResType {
|
|
6
6
|
/**
|