@zat-design/sisyphus-react 4.5.9 → 4.5.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.css +1 -1
- package/dist/less.esm.css +1 -1
- package/es/FormsProvider/index.js +14 -21
- package/es/ProAction/components/CheckModalContent/index.js +12 -26
- package/es/ProAction/index.js +79 -83
- package/es/ProAction/propsType.js +0 -1
- package/es/ProConfigProvider/index.js +63 -110
- package/es/ProConfigProvider/propsType.js +0 -1
- package/es/ProDownload/index.d.ts +2 -1
- package/es/ProDownload/index.js +74 -69
- package/es/ProDownload/propsType.js +0 -1
- package/es/ProDownload/utils.d.ts +10 -5
- package/es/ProDownload/utils.js +63 -95
- package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
- package/es/ProDrawerForm/components/ProModal/index.js +77 -108
- package/es/ProDrawerForm/components/index.js +6 -2
- package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
- package/es/ProDrawerForm/index.js +29 -38
- package/es/ProDrawerForm/propsType.js +0 -1
- package/es/ProDrawerForm/utils/index.js +18 -36
- package/es/ProEditLabel/components/RenderProForm.js +45 -49
- package/es/ProEditLabel/index.js +126 -163
- package/es/ProEditLabel/propsType.js +0 -1
- package/es/ProEditLabel/utils/index.js +5 -8
- package/es/ProEditTable/components/ActionButton/index.js +111 -119
- package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
- package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
- package/es/ProEditTable/components/RcTable/index.js +6 -4
- package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
- package/es/ProEditTable/components/RenderField/index.js +490 -587
- package/es/ProEditTable/components/RenderField/propsType.js +0 -1
- package/es/ProEditTable/components/RenderField/tools.js +115 -112
- package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
- package/es/ProEditTable/components/Summary/index.js +38 -64
- package/es/ProEditTable/components/Validator/index.js +46 -46
- package/es/ProEditTable/components/index.js +12 -5
- package/es/ProEditTable/index.js +456 -378
- package/es/ProEditTable/propsType.js +0 -1
- package/es/ProEditTable/utils/config.js +60 -122
- package/es/ProEditTable/utils/diffOriginal.js +45 -82
- package/es/ProEditTable/utils/getDefaultProps.js +19 -24
- package/es/ProEditTable/utils/index.js +154 -235
- package/es/ProEditTable/utils/tools.js +149 -286
- package/es/ProEditTable/utils/transform.js +25 -30
- package/es/ProEditTable/utils/useEditTableError.js +30 -43
- package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
- package/es/ProEditTable/utils/validateAll.js +87 -154
- package/es/ProEnum/components/Group.js +38 -30
- package/es/ProEnum/components/Tag.js +22 -26
- package/es/ProEnum/hooks/useEnum.js +48 -116
- package/es/ProEnum/hooks/useEnumRequest.js +182 -212
- package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
- package/es/ProEnum/index.js +162 -172
- package/es/ProEnum/propsType.js +0 -1
- package/es/ProEnum/utils/eventCenter.js +10 -12
- package/es/ProEnum/utils/frequentEnum.js +35 -92
- package/es/ProEnum/utils/getEnum.js +32 -90
- package/es/ProEnum/utils/getEnumLabel.js +44 -49
- package/es/ProEnum/utils/index.js +93 -207
- package/es/ProForm/components/Container.js +13 -28
- package/es/ProForm/components/FormFooter/index.js +36 -44
- package/es/ProForm/components/FormFooter/propsType.js +0 -1
- package/es/ProForm/components/base/Checkbox/index.js +32 -59
- package/es/ProForm/components/base/DatePicker/index.js +49 -71
- package/es/ProForm/components/base/Input/index.js +63 -97
- package/es/ProForm/components/base/Input/propsType.js +0 -1
- package/es/ProForm/components/base/InputNumber/index.js +118 -172
- package/es/ProForm/components/base/Radio/index.js +39 -52
- package/es/ProForm/components/base/RangePicker/index.js +109 -127
- package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
- package/es/ProForm/components/base/Select/index.js +63 -89
- package/es/ProForm/components/base/Switch/index.js +27 -35
- package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
- package/es/ProForm/components/base/TextArea/index.js +30 -41
- package/es/ProForm/components/base/TimePicker/index.js +27 -37
- package/es/ProForm/components/combination/Container/index.js +37 -47
- package/es/ProForm/components/combination/Container/propsType.js +0 -1
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
- package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -102
- package/es/ProForm/components/combination/FormList/components/Empty.js +28 -55
- package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
- package/es/ProForm/components/combination/FormList/index.js +151 -161
- package/es/ProForm/components/combination/FormList/propsType.js +0 -1
- package/es/ProForm/components/combination/FormList/style/index.less +6 -0
- package/es/ProForm/components/combination/FormList/utils.js +22 -38
- package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
- package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
- package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +106 -213
- package/es/ProForm/components/combination/Group/hooks/index.js +69 -129
- package/es/ProForm/components/combination/Group/index.js +87 -126
- package/es/ProForm/components/combination/Group/propsType.js +0 -1
- package/es/ProForm/components/combination/Group/utils/index.js +124 -239
- package/es/ProForm/components/combination/ProCascader/index.js +156 -199
- package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
- package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
- package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +72 -70
- package/es/ProForm/components/combination/ProModalSelect/index.js +309 -347
- package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
- package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
- package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
- package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
- package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
- package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
- package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
- package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
- package/es/ProForm/components/index.js +56 -34
- package/es/ProForm/components/render/ChangedWrapper.js +85 -94
- package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
- package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
- package/es/ProForm/components/render/Render.js +223 -329
- package/es/ProForm/components/render/RenderFields.js +76 -113
- package/es/ProForm/components/render/propsType.js +0 -1
- package/es/ProForm/hooks/useControlled.js +8 -10
- package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
- package/es/ProForm/hooks/useFieldProps.js +8 -4
- package/es/ProForm/hooks/useForm.js +50 -110
- package/es/ProForm/hooks/useRules.js +17 -33
- package/es/ProForm/hooks/useShouldUpdate.js +77 -152
- package/es/ProForm/hooks/useWatch.js +62 -134
- package/es/ProForm/index.js +157 -194
- package/es/ProForm/propsType.js +15 -7
- package/es/ProForm/utils/buildFormItemProps.js +51 -58
- package/es/ProForm/utils/diffOriginal.js +43 -73
- package/es/ProForm/utils/getDefaultProps.js +18 -24
- package/es/ProForm/utils/index.js +160 -235
- package/es/ProForm/utils/processDependencies.js +21 -60
- package/es/ProForm/utils/reactiveValues.js +20 -34
- package/es/ProForm/utils/rulesCreator.js +42 -40
- package/es/ProForm/utils/transformNames.js +10 -13
- package/es/ProForm/utils/transformValue.js +16 -29
- package/es/ProForm/utils/valueType.js +96 -178
- package/es/ProIcon/config/index.js +340 -274
- package/es/ProIcon/index.js +135 -209
- package/es/ProIcon/propsTypes.js +0 -1
- package/es/ProIcon/utils/index.js +24 -39
- package/es/ProLayout/components/Layout/Header/index.js +108 -141
- package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
- package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +113 -139
- package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
- package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
- package/es/ProLayout/components/Layout/Menu/index.js +92 -89
- package/es/ProLayout/components/Layout/Notice/index.js +13 -27
- package/es/ProLayout/components/Layout/index.js +8 -3
- package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
- package/es/ProLayout/components/ProCollapse/index.js +89 -111
- package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
- package/es/ProLayout/components/ProFooter/index.js +27 -24
- package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
- package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
- package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -84
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
- package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
- package/es/ProLayout/components/ProHeader/components/index.js +6 -2
- package/es/ProLayout/components/ProHeader/index.js +216 -356
- package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
- package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
- package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -63
- package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
- package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
- package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
- package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
- package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
- package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
- package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +320 -350
- package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.d.ts +19 -0
- package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +332 -0
- package/es/ProLayout/components/TabsManager/index.js +407 -351
- package/es/ProLayout/components/TabsManager/propTypes.d.ts +4 -0
- package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
- package/es/ProLayout/components/TabsManager/style/index.less +1 -1
- package/es/ProLayout/components/TabsManager/utils/historyObserver.d.ts +7 -0
- package/es/ProLayout/components/TabsManager/utils/historyObserver.js +65 -0
- package/es/ProLayout/components/TabsManager/utils/index.d.ts +15 -2
- package/es/ProLayout/components/TabsManager/utils/index.js +156 -159
- package/es/ProLayout/components/index.js +8 -3
- package/es/ProLayout/index.js +173 -228
- package/es/ProLayout/propTypes.d.ts +28 -1
- package/es/ProLayout/propTypes.js +12 -52
- package/es/ProLayout/utils/index.js +48 -128
- package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
- package/es/ProSelect/index.js +187 -223
- package/es/ProSelect/propsType.js +0 -1
- package/es/ProSelect/style/index.less +13 -0
- package/es/ProSelect/utils/index.js +100 -146
- package/es/ProStep/components/Anchor/index.js +71 -82
- package/es/ProStep/components/Item/index.js +49 -56
- package/es/ProStep/components/LazyLoad/index.js +23 -29
- package/es/ProStep/components/Listener/index.js +20 -33
- package/es/ProStep/components/Step/index.js +31 -38
- package/es/ProStep/constants.js +4 -1
- package/es/ProStep/index.js +166 -153
- package/es/ProStep/propsType.js +0 -1
- package/es/ProStep/style/index.less +1 -1
- package/es/ProStep/utils/index.js +29 -55
- package/es/ProStepTab/index.js +83 -138
- package/es/ProStepTab/propsType.js +0 -1
- package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
- package/es/ProTable/components/EditableCell/index.js +37 -71
- package/es/ProTable/components/EditableCell/propsType.js +0 -1
- package/es/ProTable/components/FormatColumn/index.js +209 -340
- package/es/ProTable/components/FormatColumn/propsType.js +0 -1
- package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
- package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
- package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
- package/es/ProTable/components/RcTable/index.js +6 -4
- package/es/ProTable/components/RenderColumn/index.js +158 -186
- package/es/ProTable/components/RenderEmptyText/index.js +12 -21
- package/es/ProTable/components/RenderFooter/index.js +15 -15
- package/es/ProTable/components/RenderSummary/index.js +33 -50
- package/es/ProTable/components/RenderTableHeader/index.js +44 -46
- package/es/ProTable/components/RenderTabs/index.js +47 -51
- package/es/ProTable/components/TableResizable/index.js +56 -72
- package/es/ProTable/components/TooltipTitle/index.js +13 -21
- package/es/ProTable/components/index.js +16 -36
- package/es/ProTable/hooks/useAntdTable.js +191 -224
- package/es/ProTable/index.js +232 -249
- package/es/ProTable/propsType.js +0 -1
- package/es/ProTable/utils/columnStorage.js +63 -88
- package/es/ProTable/utils/index.js +57 -90
- package/es/ProTabs/components/Card/index.js +20 -48
- package/es/ProTabs/components/index.js +4 -1
- package/es/ProTabs/index.js +41 -58
- package/es/ProTabs/propType.js +0 -1
- package/es/ProThemeTools/component/ProTools/index.js +106 -158
- package/es/ProThemeTools/component/index.js +4 -1
- package/es/ProThemeTools/context/ThemeContext.js +67 -146
- package/es/ProThemeTools/index.js +103 -156
- package/es/ProThemeTools/propsType.js +0 -1
- package/es/ProThemeTools/utils/index.js +60 -109
- package/es/ProTooltip/index.js +132 -168
- package/es/ProTooltip/propsType.js +0 -1
- package/es/ProTree/components/AdaptiveTooltip.js +15 -17
- package/es/ProTree/components/CloseIcon.js +18 -26
- package/es/ProTree/components/List.js +28 -47
- package/es/ProTree/components/ProTree.js +152 -211
- package/es/ProTree/components/ProTreeSelect/index.js +255 -459
- package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
- package/es/ProTree/components/SearchTitle.js +23 -42
- package/es/ProTree/components/Tree.js +147 -195
- package/es/ProTree/components/index.js +10 -5
- package/es/ProTree/index.js +12 -16
- package/es/ProTree/propsType.js +0 -1
- package/es/ProTree/utils.js +46 -118
- package/es/ProTreeModal/components/Cascader.js +56 -64
- package/es/ProTreeModal/components/CloseIcon.js +18 -26
- package/es/ProTreeModal/components/List.js +114 -180
- package/es/ProTreeModal/components/SearchTitle.js +15 -18
- package/es/ProTreeModal/components/SortableItem.js +29 -58
- package/es/ProTreeModal/components/Tree.js +99 -113
- package/es/ProTreeModal/components/Trigger.js +87 -121
- package/es/ProTreeModal/components/index.js +14 -6
- package/es/ProTreeModal/index.js +397 -438
- package/es/ProTreeModal/propsType.js +0 -1
- package/es/ProTreeModal/utils.js +52 -95
- package/es/ProUpload/components/ButtonRender.js +44 -54
- package/es/ProUpload/components/DragRender.js +94 -148
- package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
- package/es/ProUpload/components/Example.js +27 -31
- package/es/ProUpload/components/FileItem.js +69 -163
- package/es/ProUpload/components/ImageRender.js +134 -170
- package/es/ProUpload/index.js +68 -100
- package/es/ProUpload/propsType.js +0 -1
- package/es/ProUpload/uitls.js +8 -4
- package/es/ProUtils/utils/index.js +17 -13
- package/es/ProViewer/index.js +154 -175
- package/es/ProViewer/propsType.js +0 -5
- package/es/ProWaterMark/index.js +9 -16
- package/es/ProWaterMark/propsType.js +0 -1
- package/es/hooks/useDraggableRow.js +25 -53
- package/es/index.js +57 -77
- package/es/locale/en_US.js +153 -142
- package/es/locale/index.js +23 -36
- package/es/locale/zh_CN.js +145 -142
- package/es/tokens.js +84 -83
- package/es/utils/index.js +24 -51
- package/package.json +4 -2
- package/es/ProConfigProvider/demo/locale.js +0 -58
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import classNames from 'classnames';
|
|
1
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useCallback, useMemo, memo, useRef } from "react";
|
|
3
|
+
import { Form } from "antd";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
6
|
+
import isEqual from "lodash/isEqual";
|
|
7
|
+
import debounce from "lodash/debounce";
|
|
8
|
+
import omit from "lodash/omit";
|
|
9
|
+
import isFunction from "lodash/isFunction";
|
|
10
|
+
import get from "lodash/get";
|
|
12
11
|
import { compatStartTransition } from "../../../utils";
|
|
13
12
|
import valueTypeMap from "../../../ProForm/utils/valueType";
|
|
14
13
|
import transformMap from "../../utils/transform";
|
|
15
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
getNamePath,
|
|
16
|
+
difference,
|
|
17
|
+
getDisabled,
|
|
18
|
+
isRecordShallowEqual,
|
|
19
|
+
resolveChangedFields,
|
|
20
|
+
syncGroupCombinedValues
|
|
21
|
+
} from "../../utils/tools";
|
|
16
22
|
import * as componentMap from "../../../ProForm/components";
|
|
17
23
|
import { useProConfig } from "../../../ProConfigProvider";
|
|
18
24
|
import Container from "../../../ProForm/components/Container";
|
|
@@ -25,15 +31,14 @@ import ConfirmWrapper from "../../../ProForm/components/render/ConfirmWrapper";
|
|
|
25
31
|
import { getDefaultProps } from "../../utils/getDefaultProps";
|
|
26
32
|
import ListChangedWrapper from "./ListChangedWrapper";
|
|
27
33
|
import useShouldUpdateForTable from "../../utils/useShouldUpdateForTable";
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) => {
|
|
34
|
+
import {
|
|
35
|
+
OMIT_FORM_ITEM_AND_DOM_KEYS,
|
|
36
|
+
arePropsEqual,
|
|
37
|
+
hasRowFunctionDependency,
|
|
38
|
+
mergeOnFieldChangeRow
|
|
39
|
+
} from "./tools";
|
|
40
|
+
const RenderField = ({ text: value, record, index, column, config }) => {
|
|
41
|
+
var _a, _b, _c;
|
|
37
42
|
let {
|
|
38
43
|
type,
|
|
39
44
|
valueType,
|
|
@@ -70,7 +75,7 @@ const RenderField = ({
|
|
|
70
75
|
originalValues,
|
|
71
76
|
namePath: formNamePath,
|
|
72
77
|
rowDisabled,
|
|
73
|
-
validateTrigger = [
|
|
78
|
+
validateTrigger = ["onChange", "onBlur", "onSubmit"],
|
|
74
79
|
otherProps,
|
|
75
80
|
diffConfig,
|
|
76
81
|
getIsNew,
|
|
@@ -86,230 +91,175 @@ const RenderField = ({
|
|
|
86
91
|
let lastDisabled = false;
|
|
87
92
|
let lastDesensitization = desensitization || [];
|
|
88
93
|
let lastComponent = component || editRender;
|
|
89
|
-
const isSingleMode = mode ===
|
|
90
|
-
|
|
91
|
-
// type类型 首字母转大写
|
|
92
|
-
type = type?.replace?.(type[0], type[0].toUpperCase()) || 'Input';
|
|
94
|
+
const isSingleMode = mode === "single";
|
|
95
|
+
type = ((_a = type == null ? void 0 : type.replace) == null ? void 0 : _a.call(type, type[0], type[0].toUpperCase())) || "Input";
|
|
93
96
|
const fallbackType = type;
|
|
94
|
-
const hasCustomComponent =
|
|
95
|
-
|
|
96
|
-
// 自定义组件时 防止默认值影像后续判断
|
|
97
|
-
if ('component' in column) {
|
|
97
|
+
const hasCustomComponent = "component" in column || "editRender" in column;
|
|
98
|
+
if ("component" in column) {
|
|
98
99
|
type = null;
|
|
99
100
|
}
|
|
100
|
-
|
|
101
|
-
// 单行正在编辑时,临时生成一套formItem用来存储中间值,点击取消时候重置回上一次状态
|
|
102
101
|
const namePathKey = useMemo(() => {
|
|
103
102
|
const path = getNamePath(name, virtualKey);
|
|
104
|
-
return Array.isArray(path) ? path.join(
|
|
103
|
+
return Array.isArray(path) ? path.join(".") : String(path);
|
|
105
104
|
}, [name, virtualKey]);
|
|
106
105
|
const namePath = useMemo(() => getNamePath(name, virtualKey), [namePathKey, name, virtualKey]);
|
|
107
106
|
const rowNamePath = useMemo(() => [...namePath, index], [namePath, index]);
|
|
108
107
|
const rowData = form.getFieldValue(rowNamePath) || record || {};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
form,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}), [index, column?.name, rowNamePath, form]);
|
|
130
|
-
|
|
131
|
-
// 行参数 - 使用useMemo优化(新格式:values, { form, index, namePath })
|
|
108
|
+
const shouldUpdateStateCacheRef = useRef(void 0);
|
|
109
|
+
shouldUpdateStateCacheRef.current = void 0;
|
|
110
|
+
let currentValue = dataIndex ? rowData == null ? void 0 : rowData[dataIndex] : null;
|
|
111
|
+
const reactiveParams = useMemo(
|
|
112
|
+
() => ({
|
|
113
|
+
form,
|
|
114
|
+
index,
|
|
115
|
+
namePath: rowNamePath
|
|
116
|
+
}),
|
|
117
|
+
[form, index, rowNamePath]
|
|
118
|
+
);
|
|
119
|
+
const options = useMemo(
|
|
120
|
+
() => ({
|
|
121
|
+
index,
|
|
122
|
+
form,
|
|
123
|
+
name: column == null ? void 0 : column.name,
|
|
124
|
+
namePath: rowNamePath
|
|
125
|
+
}),
|
|
126
|
+
[index, column == null ? void 0 : column.name, rowNamePath, form]
|
|
127
|
+
);
|
|
132
128
|
const rowParams = useMemo(() => [rowData, reactiveParams], [rowData, reactiveParams]);
|
|
133
|
-
|
|
134
|
-
// 使用 hook 处理动态属性(带选择性防抖)
|
|
135
129
|
const dynamicProps = useShouldUpdateForTable({
|
|
136
130
|
rowParams,
|
|
137
131
|
column,
|
|
138
132
|
shouldUpdateDebounce
|
|
139
133
|
});
|
|
140
|
-
|
|
141
|
-
// required & rules & fieldProps & disabled & valueType 函数化处理
|
|
142
|
-
// 优先使用 hook 返回的值,fallback 到原始值
|
|
143
|
-
if (_isFunction(required)) {
|
|
134
|
+
if (isFunction(required)) {
|
|
144
135
|
lastRequired = dynamicProps.required ?? required(rowData, reactiveParams);
|
|
145
136
|
}
|
|
146
|
-
if (
|
|
137
|
+
if (isFunction(fieldProps)) {
|
|
147
138
|
lastFieldProps = dynamicProps.fieldProps ?? fieldProps(rowData, reactiveParams);
|
|
148
139
|
}
|
|
149
|
-
if (
|
|
140
|
+
if (isFunction(rules)) {
|
|
150
141
|
lastRules = dynamicProps.rules ?? rules(rowData, reactiveParams);
|
|
151
142
|
}
|
|
152
|
-
if (
|
|
143
|
+
if (isFunction(valueType)) {
|
|
153
144
|
lastValueType = dynamicProps.valueType ?? valueType(currentValue, rowData, {
|
|
154
145
|
index,
|
|
155
146
|
form,
|
|
156
147
|
namePath: rowNamePath,
|
|
157
|
-
name: column
|
|
148
|
+
name: column == null ? void 0 : column.name
|
|
158
149
|
});
|
|
159
150
|
}
|
|
160
|
-
if (
|
|
151
|
+
if (isFunction(desensitization)) {
|
|
161
152
|
lastDesensitization = dynamicProps.desensitization ?? desensitization(rowData, reactiveParams);
|
|
162
153
|
}
|
|
163
|
-
|
|
164
|
-
// 获取最终的disabled
|
|
165
154
|
lastDisabled = getDisabled({
|
|
166
|
-
globalControl: otherProps
|
|
167
|
-
formDisabled: otherProps
|
|
155
|
+
globalControl: otherProps == null ? void 0 : otherProps.globalControl,
|
|
156
|
+
formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
|
|
168
157
|
column,
|
|
169
|
-
tabledDisabled: config
|
|
158
|
+
tabledDisabled: config == null ? void 0 : config.disabled,
|
|
170
159
|
columnFieldProps: lastFieldProps,
|
|
171
160
|
params: rowParams
|
|
172
161
|
});
|
|
173
|
-
|
|
174
|
-
// isEditable 处理 - 优先使用 hook 返回的值
|
|
175
|
-
if (_isFunction(isEditable)) {
|
|
162
|
+
if (isFunction(isEditable)) {
|
|
176
163
|
isEditable = dynamicProps.isEditable ?? isEditable(rowData, reactiveParams);
|
|
177
164
|
}
|
|
178
|
-
|
|
179
|
-
// component 处理 - 优先使用 hook 返回的值
|
|
180
|
-
if (_isFunction(lastComponent)) {
|
|
165
|
+
if (isFunction(lastComponent)) {
|
|
181
166
|
lastComponent = dynamicProps.componentResolved ? dynamicProps.component : lastComponent(rowData, reactiveParams);
|
|
182
167
|
}
|
|
183
|
-
|
|
184
|
-
// 更新 lastEditRender 为处理后的 lastComponent
|
|
185
168
|
const lastEditRender = lastComponent;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
globalControl: otherProps?.globalControl,
|
|
190
|
-
formDisabled: otherProps?.formDisabled,
|
|
169
|
+
const isView = !isEditable || (record == null ? void 0 : record["is-view"]) || config.isView || virtualKey && !isEditing || getDisabled({
|
|
170
|
+
globalControl: otherProps == null ? void 0 : otherProps.globalControl,
|
|
171
|
+
formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
|
|
191
172
|
column,
|
|
192
|
-
tabledDisabled: config
|
|
173
|
+
tabledDisabled: config == null ? void 0 : config.disabled,
|
|
193
174
|
columnFieldProps: lastFieldProps,
|
|
194
175
|
params: rowParams,
|
|
195
|
-
rowDisabled: rowDisabled ||
|
|
176
|
+
rowDisabled: rowDisabled || "empty"
|
|
196
177
|
});
|
|
197
|
-
|
|
198
|
-
// 只读文本时,采用当前formItem的name,单行编辑时,使用生成的虚拟的name
|
|
199
178
|
const baseName = isView ? name : namePath;
|
|
200
|
-
|
|
201
|
-
// 多态:可能是内置组件类型、自定义 component,或已渲染的 ReactElement(lastEditRender),保留显式 any
|
|
202
179
|
let TargetComponent;
|
|
203
|
-
const fallbackTargetComponent = typeof fallbackType ===
|
|
180
|
+
const fallbackTargetComponent = typeof fallbackType === "string" ? componentMap[fallbackType] : void 0;
|
|
204
181
|
const invalidComponentWarnedRef = useRef(false);
|
|
205
|
-
const resolveEditTargetComponent = candidate => {
|
|
206
|
-
if (
|
|
182
|
+
const resolveEditTargetComponent = (candidate) => {
|
|
183
|
+
if (React.isValidElement(candidate)) {
|
|
207
184
|
invalidComponentWarnedRef.current = false;
|
|
208
185
|
return candidate;
|
|
209
186
|
}
|
|
210
|
-
if (hasCustomComponent && !invalidComponentWarnedRef.current &&
|
|
211
|
-
const columnName = dataIndex ?? column
|
|
212
|
-
console.warn(
|
|
213
|
-
column: Array.isArray(columnName) ? columnName.join(
|
|
187
|
+
if (hasCustomComponent && !invalidComponentWarnedRef.current && true) {
|
|
188
|
+
const columnName = dataIndex ?? (column == null ? void 0 : column.name) ?? title ?? originTitle ?? "unknown";
|
|
189
|
+
console.warn("[ProEditTable] component 必须返回合法的 ReactElement,已回退到内置组件。", {
|
|
190
|
+
column: Array.isArray(columnName) ? columnName.join(".") : String(columnName),
|
|
214
191
|
received: candidate
|
|
215
192
|
});
|
|
216
193
|
invalidComponentWarnedRef.current = true;
|
|
217
194
|
}
|
|
218
195
|
return fallbackTargetComponent;
|
|
219
196
|
};
|
|
220
|
-
|
|
221
|
-
// 将Hooks调用移到组件顶层
|
|
222
197
|
const proConfig = useProConfig();
|
|
223
|
-
|
|
224
|
-
// 设置校验规则 - 不在此处过滤 isView,由 getFieldItem 内根据 latestIsView 动态决定是否应用规则
|
|
225
198
|
const internalRule = useRules({
|
|
226
199
|
names,
|
|
227
|
-
label
|
|
200
|
+
label,
|
|
228
201
|
labelRequired,
|
|
229
202
|
required: lastRequired,
|
|
230
203
|
rules: lastRules,
|
|
231
204
|
isSelect: isSelect({
|
|
232
|
-
dataSource: lastFieldProps
|
|
205
|
+
dataSource: lastFieldProps == null ? void 0 : lastFieldProps.dataSource,
|
|
233
206
|
type
|
|
234
207
|
}),
|
|
235
208
|
type
|
|
236
209
|
});
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
name,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
// 注意:当 hasFunctionDependency 时会设置 shouldUpdate,shouldUpdate 与 dependencies 互斥,不透传 dependencies
|
|
258
|
-
}), [defaultProps, resetProps, internalRule, validateTrigger]);
|
|
259
|
-
|
|
260
|
-
// 当这些函数类型存在时,自动添加 shouldUpdate
|
|
261
|
-
// 因为这些函数依赖行数据,当行数据变化时需要重新计算
|
|
262
|
-
// 扩展到所有模式(single/multiple/cell),统一行为
|
|
263
|
-
// 注意:需要检查原始的 component/editRender,而不是处理后的 lastComponent
|
|
210
|
+
const formItemChildProps = { ...lastFieldProps };
|
|
211
|
+
const defaultProps = useMemo(
|
|
212
|
+
() => getDefaultProps({
|
|
213
|
+
name,
|
|
214
|
+
namePath: formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName,
|
|
215
|
+
type: column == null ? void 0 : column.type,
|
|
216
|
+
fieldProps: column == null ? void 0 : column.fieldProps
|
|
217
|
+
}),
|
|
218
|
+
[name, formNamePath, cellName, column == null ? void 0 : column.type, column == null ? void 0 : column.fieldProps]
|
|
219
|
+
);
|
|
220
|
+
const lastFormItemProps = useMemo(
|
|
221
|
+
() => ({
|
|
222
|
+
...defaultProps,
|
|
223
|
+
...omit(resetProps, OMIT_FORM_ITEM_AND_DOM_KEYS),
|
|
224
|
+
...internalRule,
|
|
225
|
+
validateTrigger
|
|
226
|
+
// 注意:当 hasFunctionDependency 时会设置 shouldUpdate,shouldUpdate 与 dependencies 互斥,不透传 dependencies
|
|
227
|
+
}),
|
|
228
|
+
[defaultProps, resetProps, internalRule, validateTrigger]
|
|
229
|
+
);
|
|
264
230
|
const hasFunctionDependency = hasRowFunctionDependency(column);
|
|
265
|
-
|
|
266
|
-
// 移除 isSingleMode 限制,让所有模式都支持响应式更新
|
|
267
|
-
// 性能优化已通过 useShouldUpdateForTable hook 的缓存和防抖机制实现
|
|
268
231
|
if (hasFunctionDependency) {
|
|
269
|
-
// 使用 shouldUpdate 监听同一行的数据变化;shouldUpdate 与 dependencies 互斥,始终优先 shouldUpdate
|
|
270
232
|
lastFormItemProps.shouldUpdate = (prevValues, currentValues) => {
|
|
271
|
-
const prevRow =
|
|
272
|
-
const currentRow =
|
|
273
|
-
|
|
274
|
-
return !_isEqual(prevRow, currentRow);
|
|
233
|
+
const prevRow = get(prevValues, rowNamePath);
|
|
234
|
+
const currentRow = get(currentValues, rowNamePath);
|
|
235
|
+
return !isEqual(prevRow, currentRow);
|
|
275
236
|
};
|
|
276
237
|
}
|
|
277
|
-
if ([
|
|
278
|
-
lastFormItemProps.valuePropName =
|
|
279
|
-
lastValueType =
|
|
238
|
+
if (["Switch", "SwitchCheckbox"].includes(type)) {
|
|
239
|
+
lastFormItemProps.valuePropName = "checked";
|
|
240
|
+
lastValueType = "switch";
|
|
280
241
|
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* 针对一些特殊类型,基于formItem的normalize与getValueProps进行默认值类型转换
|
|
284
|
-
* @returns {}
|
|
285
|
-
*/
|
|
286
242
|
const defaultTransform = useCallback(() => {
|
|
287
|
-
|
|
243
|
+
var _a2, _b2;
|
|
244
|
+
const types = ["DatePicker", "RangePicker"];
|
|
288
245
|
if (!lastValueType && types.includes(type)) {
|
|
289
|
-
return transformMap
|
|
246
|
+
return (_b2 = (_a2 = transformMap) == null ? void 0 : _a2[type]) == null ? void 0 : _b2.call(_a2, lastFieldProps || {});
|
|
290
247
|
}
|
|
291
248
|
return {};
|
|
292
249
|
}, [lastValueType, type, lastFieldProps]);
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* 配置valueType时,基于formItem的normalize与getValueProps进行值类型转换
|
|
296
|
-
* @returns {}
|
|
297
|
-
*/
|
|
298
250
|
const valueTypeTransform = useCallback(() => {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
lastValueType = 'switch';
|
|
251
|
+
if (type === "SwitchCheckbox") {
|
|
252
|
+
lastValueType = "switch";
|
|
302
253
|
}
|
|
303
254
|
const params = {
|
|
304
255
|
...column,
|
|
305
|
-
mode: lastFieldProps
|
|
256
|
+
mode: lastFieldProps == null ? void 0 : lastFieldProps.mode
|
|
306
257
|
};
|
|
307
258
|
const valueTypeKey = lastValueType;
|
|
308
|
-
return
|
|
309
|
-
}, [type, lastValueType, column, lastFieldProps
|
|
310
|
-
if (names
|
|
311
|
-
|
|
312
|
-
names = names.map(key => {
|
|
259
|
+
return isFunction(valueTypeMap[valueTypeKey]) ? valueTypeMap[valueTypeKey](params) : {};
|
|
260
|
+
}, [type, lastValueType, column, lastFieldProps == null ? void 0 : lastFieldProps.mode]);
|
|
261
|
+
if (names == null ? void 0 : names.length) {
|
|
262
|
+
names = names.map((key) => {
|
|
313
263
|
if (Array.isArray(key)) {
|
|
314
264
|
return [...baseName, index, ...key];
|
|
315
265
|
}
|
|
@@ -319,210 +269,188 @@ const RenderField = ({
|
|
|
319
269
|
let originalName = cellName;
|
|
320
270
|
let originalNames = names;
|
|
321
271
|
if (virtualKey) {
|
|
322
|
-
originalName = [...name, ...cellName
|
|
323
|
-
originalNames = names
|
|
324
|
-
|
|
272
|
+
originalName = [...name, ...(_b = cellName == null ? void 0 : cellName.slice) == null ? void 0 : _b.call(cellName, name.length)];
|
|
273
|
+
originalNames = (_c = names == null ? void 0 : names.map) == null ? void 0 : _c.call(names, (item) => {
|
|
274
|
+
var _a2;
|
|
275
|
+
return [...name, ...(_a2 = item == null ? void 0 : item.slice) == null ? void 0 : _a2.call(item, name.length)];
|
|
325
276
|
});
|
|
326
277
|
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* 配置names时,基于formItem的normalize与getValueProps进行值类型转换
|
|
330
|
-
* @returns {}
|
|
331
|
-
*/
|
|
332
278
|
const namesTransform = useCallback(() => {
|
|
333
|
-
if (!names
|
|
279
|
+
if (!(names == null ? void 0 : names.length)) {
|
|
334
280
|
return valueTypeTransform();
|
|
335
281
|
}
|
|
336
282
|
const namesStr = [...baseName, index, dataIndex];
|
|
337
|
-
return transformNames(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
283
|
+
return transformNames(
|
|
284
|
+
{
|
|
285
|
+
...lastFormItemProps,
|
|
286
|
+
...valueTypeTransform()
|
|
287
|
+
},
|
|
288
|
+
form,
|
|
289
|
+
names,
|
|
290
|
+
namesStr,
|
|
291
|
+
type
|
|
292
|
+
);
|
|
341
293
|
}, [names, baseName, index, dataIndex, lastFormItemProps, type]);
|
|
342
294
|
TargetComponent = fallbackTargetComponent;
|
|
343
295
|
if (isEditable && isEditing && hasCustomComponent) {
|
|
344
296
|
TargetComponent = resolveEditTargetComponent(lastEditRender);
|
|
345
297
|
}
|
|
346
|
-
|
|
347
|
-
// 查看模式
|
|
348
298
|
if (isView) {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const latestCurrentValue = dataIndex ? rowData?.[dataIndex] : value;
|
|
299
|
+
if (typeof viewRender === "function") {
|
|
300
|
+
const latestCurrentValue = dataIndex ? rowData == null ? void 0 : rowData[dataIndex] : value;
|
|
352
301
|
const View = viewRender(latestCurrentValue, rowData || {}, options);
|
|
353
|
-
TargetComponent =
|
|
354
|
-
viewEmpty: viewEmpty,
|
|
355
|
-
children: View
|
|
356
|
-
});
|
|
302
|
+
TargetComponent = /* @__PURE__ */ jsx(Container, { viewEmpty, children: View });
|
|
357
303
|
}
|
|
358
|
-
if (
|
|
304
|
+
if (React.isValidElement(viewRender)) {
|
|
359
305
|
TargetComponent = viewRender;
|
|
360
306
|
}
|
|
361
307
|
}
|
|
362
|
-
const onChange = formItemChildProps
|
|
363
|
-
const onFieldChange = formItemChildProps
|
|
364
|
-
const onBlur = formItemChildProps
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
default:
|
|
390
|
-
break;
|
|
391
|
-
}
|
|
392
|
-
return nextArgs;
|
|
393
|
-
}, [options, type]);
|
|
394
|
-
|
|
395
|
-
// 使用useCallback优化debounceValidate函数
|
|
396
|
-
const debounceValidate = useCallback((validateFieldKeys = []) => {
|
|
397
|
-
setTimeout(() => {
|
|
398
|
-
// 行内联动被动触发的重校验:只校验、不滚动到报错位置(全局/主动保存校验仍会滚动)
|
|
399
|
-
// @ts-ignore 内部选项
|
|
400
|
-
form.validateFields(validateFieldKeys, {
|
|
401
|
-
recursive: true,
|
|
402
|
-
__skipScrollOnError: true
|
|
403
|
-
});
|
|
404
|
-
}, 100);
|
|
405
|
-
}, [form]);
|
|
406
|
-
|
|
407
|
-
// 使用 useRef 保存防抖函数
|
|
408
|
-
const debounceRef = useRef(null);
|
|
409
|
-
|
|
410
|
-
// 使用 useCallback 创建稳定的 onChange 函数
|
|
411
|
-
const handleChange = useCallback(async (...args) => {
|
|
412
|
-
const executeChange = async (...innerArgs) => {
|
|
413
|
-
// 虚拟表格:用户编辑本单元格 → 清掉旧的常驻报错,提交时再以最新值统一重校
|
|
414
|
-
if (virtual && errorStore && record?.rowKey != null) {
|
|
415
|
-
errorStore.clearCell(record.rowKey, String(column?.dataIndex));
|
|
308
|
+
const onChange = formItemChildProps == null ? void 0 : formItemChildProps.onChange;
|
|
309
|
+
const onFieldChange = formItemChildProps == null ? void 0 : formItemChildProps.onFieldChange;
|
|
310
|
+
const onBlur = formItemChildProps == null ? void 0 : formItemChildProps.onBlur;
|
|
311
|
+
const formatArgs = useCallback(
|
|
312
|
+
(...args) => {
|
|
313
|
+
const rawArgs = (args == null ? void 0 : args.length) === 1 && Array.isArray(args == null ? void 0 : args[0]) ? args == null ? void 0 : args[0] : args;
|
|
314
|
+
const nextArgs = [];
|
|
315
|
+
nextArgs[0] = rawArgs == null ? void 0 : rawArgs[0];
|
|
316
|
+
nextArgs[2] = {
|
|
317
|
+
...options,
|
|
318
|
+
extra: rawArgs
|
|
319
|
+
};
|
|
320
|
+
switch (type) {
|
|
321
|
+
case "ProSelect":
|
|
322
|
+
case "ProModalSelect":
|
|
323
|
+
case "ProEnum":
|
|
324
|
+
nextArgs[2].option = rawArgs == null ? void 0 : rawArgs[1];
|
|
325
|
+
break;
|
|
326
|
+
case "ProCascader":
|
|
327
|
+
nextArgs[2].selectedOptions = rawArgs == null ? void 0 : rawArgs[1];
|
|
328
|
+
break;
|
|
329
|
+
case "DatePicker":
|
|
330
|
+
case "RangePicker":
|
|
331
|
+
nextArgs[2].dateString = rawArgs == null ? void 0 : rawArgs[1];
|
|
332
|
+
break;
|
|
333
|
+
default:
|
|
334
|
+
break;
|
|
416
335
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
336
|
+
return nextArgs;
|
|
337
|
+
},
|
|
338
|
+
[options, type]
|
|
339
|
+
);
|
|
340
|
+
const debounceValidate = useCallback(
|
|
341
|
+
(validateFieldKeys = []) => {
|
|
342
|
+
setTimeout(() => {
|
|
343
|
+
form.validateFields(validateFieldKeys, { recursive: true, __skipScrollOnError: true });
|
|
344
|
+
}, 100);
|
|
345
|
+
},
|
|
346
|
+
[form]
|
|
347
|
+
);
|
|
348
|
+
const debounceRef = useRef(null);
|
|
349
|
+
const handleChange = useCallback(
|
|
350
|
+
async (...args) => {
|
|
351
|
+
const executeChange = async (...innerArgs) => {
|
|
352
|
+
var _a2, _b2, _c2;
|
|
353
|
+
if (virtual && errorStore && (record == null ? void 0 : record.rowKey) != null) {
|
|
354
|
+
errorStore.clearCell(record.rowKey, String(column == null ? void 0 : column.dataIndex));
|
|
429
355
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
// 原地修改 row 会改变 store 内的对象,但不会通知 Form 和只读单元格重新渲染。
|
|
441
|
-
// 只通知相对回调前真正变化的子字段,避免整行回写覆盖回调内显式 setFieldValue 的新值。
|
|
442
|
-
const latestStoreRow = form.getFieldValue(rowPath, true) || {};
|
|
443
|
-
const nextStoreRow = mergeOnFieldChangeRow(orgRow, row, latestStoreRow);
|
|
444
|
-
if (nextStoreRow !== latestStoreRow) {
|
|
445
|
-
// ProEditTable 注册在整个列表路径上,子行写入不会通知该 Form.Item。
|
|
446
|
-
// 以最新列表为底只替换当前行,确保其他行与显式 store 写入不被覆盖。
|
|
447
|
-
const latestList = form.getFieldValue(namePath, true) || [];
|
|
448
|
-
const nextList = [...latestList];
|
|
449
|
-
nextList[index] = nextStoreRow;
|
|
450
|
-
form.setFieldValue(namePath, nextList);
|
|
356
|
+
let callArgs = [...innerArgs];
|
|
357
|
+
const rowPath = rowNamePath;
|
|
358
|
+
if (!onFieldChange && !onChange) {
|
|
359
|
+
if (dependencies == null ? void 0 : dependencies.length) {
|
|
360
|
+
const validateFieldKeys = (_a2 = dependencies == null ? void 0 : dependencies.map) == null ? void 0 : _a2.call(dependencies, (key) => [...rowPath, key]);
|
|
361
|
+
setTimeout(() => {
|
|
362
|
+
form.validateFields(validateFieldKeys, { __skipScrollOnError: true });
|
|
363
|
+
}, 100);
|
|
364
|
+
}
|
|
365
|
+
return;
|
|
451
366
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
367
|
+
const row = form.getFieldValue(rowPath, true);
|
|
368
|
+
const orgRow = cloneDeep(row);
|
|
369
|
+
if (onFieldChange) {
|
|
370
|
+
callArgs = formatArgs(innerArgs);
|
|
371
|
+
callArgs[1] = row;
|
|
372
|
+
((_b2 = TargetComponent == null ? void 0 : TargetComponent.props) == null ? void 0 : _b2.onFieldChange) && await TargetComponent.props.onFieldChange(...callArgs);
|
|
373
|
+
onFieldChange && await onFieldChange(...callArgs);
|
|
374
|
+
const latestStoreRow = form.getFieldValue(rowPath, true) || {};
|
|
375
|
+
const nextStoreRow = mergeOnFieldChangeRow(orgRow, row, latestStoreRow);
|
|
376
|
+
if (nextStoreRow !== latestStoreRow) {
|
|
377
|
+
const latestList = form.getFieldValue(namePath, true) || [];
|
|
378
|
+
const nextList = [...latestList];
|
|
379
|
+
nextList[index] = nextStoreRow;
|
|
380
|
+
form.setFieldValue(namePath, nextList);
|
|
381
|
+
}
|
|
382
|
+
setTimeout(() => {
|
|
383
|
+
const rowAfter = form.getFieldValue(rowPath, true) ?? row;
|
|
384
|
+
if (validateTrigger && validateTrigger.includes("onChange")) {
|
|
385
|
+
if (!isEqual(orgRow, rowAfter)) {
|
|
386
|
+
const diff = difference(rowAfter, orgRow) || {};
|
|
387
|
+
const changedKeys = Object.keys(diff);
|
|
388
|
+
syncGroupCombinedValues(form, rowPath, changedKeys, columns);
|
|
389
|
+
const changedFields = resolveChangedFields(changedKeys, columns);
|
|
390
|
+
if (virtual && errorStore && (record == null ? void 0 : record.rowKey) != null) {
|
|
391
|
+
changedFields.forEach((id) => errorStore.clearCell(record.rowKey, id));
|
|
392
|
+
}
|
|
393
|
+
const validateFieldKeys = changedFields.map((id) => [...rowPath, id]).concat(dependencies || []);
|
|
394
|
+
if (validateFieldKeys == null ? void 0 : validateFieldKeys.length) {
|
|
395
|
+
debounceValidate(validateFieldKeys);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (!isEqual(orgRow, rowAfter)) {
|
|
400
|
+
compatStartTransition(() => {
|
|
401
|
+
setState({
|
|
402
|
+
forceUpdate: {
|
|
403
|
+
rowKey: record == null ? void 0 : record.rowKey
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}, 0);
|
|
409
|
+
} else {
|
|
410
|
+
callArgs = callArgs.concat([row, index, form]);
|
|
411
|
+
((_c2 = TargetComponent == null ? void 0 : TargetComponent.props) == null ? void 0 : _c2.onChange) && await TargetComponent.props.onChange(...callArgs);
|
|
412
|
+
onChange && await onChange(...callArgs);
|
|
413
|
+
const rowAfter = row;
|
|
414
|
+
form.setFieldValue(rowPath, rowAfter);
|
|
415
|
+
if (validateTrigger && validateTrigger.includes("onChange")) {
|
|
416
|
+
if (!isEqual(orgRow, rowAfter)) {
|
|
458
417
|
const diff = difference(rowAfter, orgRow) || {};
|
|
459
418
|
const changedKeys = Object.keys(diff);
|
|
460
|
-
// 联动回填只写了子键,names 组合列的合并字段值未同步 → 先按子键组合写回,确保校验读到最新值
|
|
461
419
|
syncGroupCombinedValues(form, rowPath, changedKeys, columns);
|
|
462
|
-
// 把变更子键映射回所属列字段名(names 组合列 → 合并名),否则 group 列重校验路径对不上、旧报错不清
|
|
463
420
|
const changedFields = resolveChangedFields(changedKeys, columns);
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
changedFields.forEach(id => errorStore.clearCell(record.rowKey, id));
|
|
421
|
+
if (virtual && errorStore && (record == null ? void 0 : record.rowKey) != null) {
|
|
422
|
+
changedFields.forEach((id) => errorStore.clearCell(record.rowKey, id));
|
|
467
423
|
}
|
|
468
|
-
const validateFieldKeys = changedFields.map(id => [...rowPath, id]).concat(dependencies || []);
|
|
469
|
-
if (validateFieldKeys
|
|
424
|
+
const validateFieldKeys = changedFields.map((id) => [...rowPath, id]).concat(dependencies || []);
|
|
425
|
+
if (validateFieldKeys == null ? void 0 : validateFieldKeys.length) {
|
|
470
426
|
debounceValidate(validateFieldKeys);
|
|
471
427
|
}
|
|
472
428
|
}
|
|
473
429
|
}
|
|
474
|
-
if (!_isEqual(orgRow, rowAfter)) {
|
|
475
|
-
compatStartTransition(() => {
|
|
476
|
-
setState({
|
|
477
|
-
forceUpdate: {
|
|
478
|
-
rowKey: record?.rowKey
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
}, 0);
|
|
484
|
-
} else {
|
|
485
|
-
callArgs = callArgs.concat([row, index, form]);
|
|
486
|
-
TargetComponent?.props?.onChange && (await TargetComponent.props.onChange(...callArgs));
|
|
487
|
-
onChange && (await onChange(...callArgs));
|
|
488
|
-
const rowAfter = row;
|
|
489
|
-
form.setFieldValue(rowPath, rowAfter);
|
|
490
|
-
if (validateTrigger && validateTrigger.includes('onChange')) {
|
|
491
|
-
if (!_isEqual(orgRow, rowAfter)) {
|
|
492
|
-
const diff = difference(rowAfter, orgRow) || {};
|
|
493
|
-
const changedKeys = Object.keys(diff);
|
|
494
|
-
// 联动回填只写了子键,names 组合列的合并字段值未同步 → 先按子键组合写回,确保校验读到最新值
|
|
495
|
-
syncGroupCombinedValues(form, rowPath, changedKeys, columns);
|
|
496
|
-
// 把变更子键映射回所属列字段名(names 组合列 → 合并名),否则 group 列重校验路径对不上、旧报错不清
|
|
497
|
-
const changedFields = resolveChangedFields(changedKeys, columns);
|
|
498
|
-
if (virtual && errorStore && record?.rowKey != null) {
|
|
499
|
-
changedFields.forEach(id => errorStore.clearCell(record.rowKey, id));
|
|
500
|
-
}
|
|
501
|
-
const validateFieldKeys = changedFields.map(id => [...rowPath, id]).concat(dependencies || []);
|
|
502
|
-
if (validateFieldKeys?.length) {
|
|
503
|
-
debounceValidate(validateFieldKeys);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
430
|
}
|
|
431
|
+
};
|
|
432
|
+
if (onFieldChange) {
|
|
433
|
+
await executeChange(...args);
|
|
434
|
+
return;
|
|
507
435
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
436
|
+
if (!debounceRef.current) {
|
|
437
|
+
debounceRef.current = debounce(executeChange, 300);
|
|
438
|
+
}
|
|
439
|
+
debounceRef.current(...args);
|
|
440
|
+
},
|
|
441
|
+
[
|
|
442
|
+
namePath,
|
|
443
|
+
index,
|
|
444
|
+
dependencies,
|
|
445
|
+
formatArgs,
|
|
446
|
+
onChange,
|
|
447
|
+
onFieldChange,
|
|
448
|
+
form,
|
|
449
|
+
setState,
|
|
450
|
+
TargetComponent,
|
|
451
|
+
validateTrigger
|
|
452
|
+
]
|
|
453
|
+
);
|
|
526
454
|
useEffect(() => {
|
|
527
455
|
return () => {
|
|
528
456
|
if (debounceRef.current) {
|
|
@@ -530,120 +458,138 @@ const RenderField = ({
|
|
|
530
458
|
}
|
|
531
459
|
};
|
|
532
460
|
}, []);
|
|
533
|
-
|
|
534
|
-
// 虚拟表格:单元格(重新)挂载时,回填 errorStore 中已存储的真实报错,实现报错常驻。
|
|
535
|
-
// 虚拟滚动会卸载视口外行的 Field 实体导致 antd 报错丢失,重新挂载后由此恢复红字。
|
|
536
461
|
useEffect(() => {
|
|
537
|
-
if (!virtual || !errorStore || record
|
|
462
|
+
if (!virtual || !errorStore || (record == null ? void 0 : record.rowKey) == null) {
|
|
538
463
|
return;
|
|
539
464
|
}
|
|
540
|
-
const cellKey = String(column
|
|
465
|
+
const cellKey = String(column == null ? void 0 : column.dataIndex);
|
|
541
466
|
const errs = errorStore.get(record.rowKey, cellKey);
|
|
542
|
-
if (errs
|
|
543
|
-
const fieldName = formNamePath ? cellName.slice(formNamePath
|
|
544
|
-
form.setFields([{
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
// 使用useCallback优化handleBlur函数
|
|
553
|
-
const handleBlur = useCallback(async (...args) => {
|
|
554
|
-
if (!onBlur) {
|
|
555
|
-
return;
|
|
556
|
-
}
|
|
557
|
-
let callArgs = formatArgs(...args);
|
|
558
|
-
const rowPath = rowNamePath;
|
|
559
|
-
const row = form.getFieldValue(rowPath, true);
|
|
560
|
-
const orgRow = _cloneDeep(row);
|
|
561
|
-
callArgs[1] = row;
|
|
562
|
-
TargetComponent?.props?.onBlur && (await TargetComponent.props.onBlur(...callArgs));
|
|
563
|
-
onBlur && (await onBlur(...callArgs));
|
|
564
|
-
// 判断属性是否变动
|
|
565
|
-
form.setFieldValue(rowPath, row);
|
|
566
|
-
if (validateTrigger && validateTrigger.includes('onBlur')) {
|
|
567
|
-
if (!_isEqual(orgRow, row)) {
|
|
568
|
-
const diff = difference(row, orgRow) || {};
|
|
569
|
-
const validateFieldKeys = Object.keys(diff)?.map?.(key => [...rowPath, key]).concat(dependencies || []);
|
|
570
|
-
if (validateFieldKeys?.length) {
|
|
571
|
-
debounceValidate(validateFieldKeys);
|
|
572
|
-
}
|
|
467
|
+
if (errs == null ? void 0 : errs.length) {
|
|
468
|
+
const fieldName = formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName;
|
|
469
|
+
form.setFields([{ name: fieldName, errors: errs }]);
|
|
470
|
+
}
|
|
471
|
+
}, [virtual, record == null ? void 0 : record.rowKey, column == null ? void 0 : column.dataIndex]);
|
|
472
|
+
const handleBlur = useCallback(
|
|
473
|
+
async (...args) => {
|
|
474
|
+
var _a2, _b2, _c2;
|
|
475
|
+
if (!onBlur) {
|
|
476
|
+
return;
|
|
573
477
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
478
|
+
let callArgs = formatArgs(...args);
|
|
479
|
+
const rowPath = rowNamePath;
|
|
480
|
+
const row = form.getFieldValue(rowPath, true);
|
|
481
|
+
const orgRow = cloneDeep(row);
|
|
482
|
+
callArgs[1] = row;
|
|
483
|
+
((_a2 = TargetComponent == null ? void 0 : TargetComponent.props) == null ? void 0 : _a2.onBlur) && await TargetComponent.props.onBlur(...callArgs);
|
|
484
|
+
onBlur && await onBlur(...callArgs);
|
|
485
|
+
form.setFieldValue(rowPath, row);
|
|
486
|
+
if (validateTrigger && validateTrigger.includes("onBlur")) {
|
|
487
|
+
if (!isEqual(orgRow, row)) {
|
|
488
|
+
const diff = difference(row, orgRow) || {};
|
|
489
|
+
const validateFieldKeys = (_c2 = (_b2 = Object.keys(diff)) == null ? void 0 : _b2.map) == null ? void 0 : _c2.call(_b2, (key) => [...rowPath, key]).concat(dependencies || []);
|
|
490
|
+
if (validateFieldKeys == null ? void 0 : validateFieldKeys.length) {
|
|
491
|
+
debounceValidate(validateFieldKeys);
|
|
492
|
+
}
|
|
580
493
|
}
|
|
494
|
+
}
|
|
495
|
+
compatStartTransition(() => {
|
|
496
|
+
setState({
|
|
497
|
+
forceUpdate: {
|
|
498
|
+
rowKey: record == null ? void 0 : record.rowKey
|
|
499
|
+
}
|
|
500
|
+
});
|
|
581
501
|
});
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
name: cellName,
|
|
589
|
-
...lastFieldProps,
|
|
590
|
-
...TargetComponent?.props,
|
|
591
|
-
namePath: rowNamePath,
|
|
592
|
-
disabled: lastDisabled,
|
|
593
|
-
onChange: handleChange,
|
|
594
|
-
onBlur: handleBlur,
|
|
595
|
-
index,
|
|
596
|
-
confirm,
|
|
597
|
-
desensitization: lastDesensitization,
|
|
598
|
-
otherProps: {
|
|
502
|
+
},
|
|
503
|
+
[
|
|
504
|
+
onBlur,
|
|
505
|
+
formatArgs,
|
|
506
|
+
namePath,
|
|
507
|
+
index,
|
|
599
508
|
form,
|
|
600
|
-
|
|
509
|
+
TargetComponent,
|
|
510
|
+
validateTrigger,
|
|
511
|
+
debounceValidate,
|
|
512
|
+
cellName,
|
|
513
|
+
setState
|
|
514
|
+
]
|
|
515
|
+
);
|
|
516
|
+
let componentProps = useMemo(
|
|
517
|
+
() => ({
|
|
518
|
+
form,
|
|
519
|
+
name: cellName,
|
|
520
|
+
...lastFieldProps,
|
|
521
|
+
...TargetComponent == null ? void 0 : TargetComponent.props,
|
|
601
522
|
namePath: rowNamePath,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
523
|
+
disabled: lastDisabled,
|
|
524
|
+
onChange: handleChange,
|
|
525
|
+
onBlur: handleBlur,
|
|
526
|
+
index,
|
|
527
|
+
confirm,
|
|
528
|
+
desensitization: lastDesensitization,
|
|
529
|
+
otherProps: {
|
|
530
|
+
form,
|
|
531
|
+
names,
|
|
532
|
+
namePath: rowNamePath,
|
|
533
|
+
name: originalName,
|
|
534
|
+
listName: cellName,
|
|
535
|
+
// 用于下拉框去重消费,保持和formlist一致
|
|
536
|
+
viewEmpty,
|
|
537
|
+
valueType: lastValueType,
|
|
538
|
+
isView,
|
|
539
|
+
desensitizationKey: otherProps == null ? void 0 : otherProps.desensitizationKey,
|
|
540
|
+
source: "ProEditTable"
|
|
541
|
+
}
|
|
542
|
+
}),
|
|
543
|
+
[
|
|
544
|
+
cellName,
|
|
545
|
+
lastFieldProps,
|
|
546
|
+
TargetComponent == null ? void 0 : TargetComponent.props,
|
|
547
|
+
namePath,
|
|
548
|
+
index,
|
|
549
|
+
lastDisabled,
|
|
550
|
+
handleChange,
|
|
551
|
+
handleBlur,
|
|
552
|
+
confirm,
|
|
553
|
+
lastDesensitization,
|
|
554
|
+
names,
|
|
555
|
+
originalName,
|
|
605
556
|
viewEmpty,
|
|
606
|
-
|
|
557
|
+
lastValueType,
|
|
607
558
|
isView,
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
559
|
+
otherProps == null ? void 0 : otherProps.desensitizationKey
|
|
560
|
+
]
|
|
561
|
+
);
|
|
562
|
+
componentProps = omit(componentProps, [
|
|
563
|
+
"onFieldChange",
|
|
564
|
+
"namePath",
|
|
565
|
+
"index",
|
|
566
|
+
// precision 是 InputNumber 的有效 fieldProps,仅在真正渲染原生 DOM 时过滤
|
|
567
|
+
...OMIT_FORM_ITEM_AND_DOM_KEYS.filter((key) => key !== "precision")
|
|
568
|
+
]);
|
|
569
|
+
if (["Switch", "SwitchCheckbox"].includes(type)) {
|
|
570
|
+
lastFormItemProps.valuePropName = "checked";
|
|
617
571
|
}
|
|
618
|
-
|
|
619
|
-
// 可编辑表格默认关闭scrollFollowParent
|
|
620
|
-
if (['Select', 'ProSelect', 'ProEnum'].includes(type)) {
|
|
572
|
+
if (["Select", "ProSelect", "ProEnum"].includes(type)) {
|
|
621
573
|
componentProps.scrollFollowParent = false;
|
|
622
574
|
}
|
|
623
|
-
|
|
624
|
-
// 使用useMemo优化最终的formItemProps - 修复Hooks使用规则
|
|
625
575
|
const finalFormItemProps = useMemo(() => {
|
|
626
576
|
const defaultTransformProps = defaultTransform();
|
|
627
577
|
const namesTransformProps = namesTransform();
|
|
628
|
-
const trimProps = isTrim(type, trim, proConfig);
|
|
629
|
-
|
|
630
|
-
const
|
|
631
|
-
const
|
|
632
|
-
const
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const userValue = userNormalize(value, prevValue, allValues, isDiffMode);
|
|
637
|
-
// 保持用户优先:用户有明确返回值时直接使用,不再强制走内置转换
|
|
638
|
-
if (userValue !== undefined) {
|
|
578
|
+
const trimProps = isTrim(type, trim, proConfig);
|
|
579
|
+
const transformNormalize = (namesTransformProps == null ? void 0 : namesTransformProps.normalize) ?? (defaultTransformProps == null ? void 0 : defaultTransformProps.normalize);
|
|
580
|
+
const userNormalize = lastFormItemProps == null ? void 0 : lastFormItemProps.normalize;
|
|
581
|
+
const transformGetValueProps = (namesTransformProps == null ? void 0 : namesTransformProps.getValueProps) ?? (defaultTransformProps == null ? void 0 : defaultTransformProps.getValueProps);
|
|
582
|
+
const userGetValueProps = lastFormItemProps == null ? void 0 : lastFormItemProps.getValueProps;
|
|
583
|
+
const finalNormalize = transformNormalize && userNormalize ? (value2, prevValue, allValues, isDiffMode) => {
|
|
584
|
+
const userValue = userNormalize(value2, prevValue, allValues, isDiffMode);
|
|
585
|
+
if (userValue !== void 0) {
|
|
639
586
|
return userValue;
|
|
640
587
|
}
|
|
641
|
-
|
|
642
|
-
return transformNormalize(value, prevValue, allValues, isDiffMode);
|
|
588
|
+
return transformNormalize(value2, prevValue, allValues, isDiffMode);
|
|
643
589
|
} : userNormalize || transformNormalize;
|
|
644
|
-
const finalGetValueProps = transformGetValueProps && userGetValueProps ? (
|
|
645
|
-
const transformValueProps = transformGetValueProps(
|
|
646
|
-
const nextValue = Object.prototype.hasOwnProperty.call(transformValueProps,
|
|
590
|
+
const finalGetValueProps = transformGetValueProps && userGetValueProps ? (value2, ...args) => {
|
|
591
|
+
const transformValueProps = transformGetValueProps(value2, ...args) || {};
|
|
592
|
+
const nextValue = Object.prototype.hasOwnProperty.call(transformValueProps, "value") ? transformValueProps.value : value2;
|
|
647
593
|
const userValueProps = userGetValueProps(nextValue, ...args) || {};
|
|
648
594
|
return {
|
|
649
595
|
...transformValueProps,
|
|
@@ -659,16 +605,13 @@ const RenderField = ({
|
|
|
659
605
|
getValueProps: finalGetValueProps
|
|
660
606
|
};
|
|
661
607
|
}, [lastFormItemProps, defaultTransform, namesTransform, type, trim, proConfig]);
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
[className]
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
// shouldUpdate 模式下重新获取最新行数据并重算所有响应式属性,返回最新渲染状态(不修改外层闭包)
|
|
608
|
+
const cellClassName = useMemo(
|
|
609
|
+
() => classNames({
|
|
610
|
+
[className]: className
|
|
611
|
+
}),
|
|
612
|
+
[className]
|
|
613
|
+
);
|
|
670
614
|
const recalcShouldUpdateState = () => {
|
|
671
|
-
// 重新获取最新的行数据(shouldUpdate 触发时,通过 getFieldValue 拿到最新值)
|
|
672
615
|
const latestRowData = form.getFieldValue(rowNamePath) || record || {};
|
|
673
616
|
const latestReactiveParams = {
|
|
674
617
|
form,
|
|
@@ -680,54 +623,49 @@ const RenderField = ({
|
|
|
680
623
|
if (cachedState && isRecordShallowEqual(cachedState.rowSnapshot, latestRowData)) {
|
|
681
624
|
return cachedState.result;
|
|
682
625
|
}
|
|
683
|
-
|
|
684
|
-
// 初次 render props 会与外层 RenderField 使用同一行数据,直接复用 hook 已计算结果。
|
|
685
626
|
const canReuseCurrentState = isRecordShallowEqual(latestRowData, dynamicProps.rowSnapshot);
|
|
686
627
|
let latestFieldProps = canReuseCurrentState ? lastFieldProps : fieldProps || {};
|
|
687
|
-
if (!canReuseCurrentState &&
|
|
628
|
+
if (!canReuseCurrentState && isFunction(fieldProps)) {
|
|
688
629
|
latestFieldProps = fieldProps(latestRowData, latestReactiveParams);
|
|
689
630
|
}
|
|
690
631
|
let latestRequired = canReuseCurrentState ? lastRequired : required;
|
|
691
|
-
if (!canReuseCurrentState &&
|
|
632
|
+
if (!canReuseCurrentState && isFunction(required)) {
|
|
692
633
|
latestRequired = required(latestRowData, latestReactiveParams);
|
|
693
634
|
}
|
|
694
635
|
let latestRules = canReuseCurrentState ? lastRules : rules;
|
|
695
|
-
if (!canReuseCurrentState &&
|
|
636
|
+
if (!canReuseCurrentState && isFunction(rules)) {
|
|
696
637
|
latestRules = rules(latestRowData, latestReactiveParams);
|
|
697
638
|
}
|
|
698
639
|
let latestDesensitization = canReuseCurrentState ? lastDesensitization : desensitization || [];
|
|
699
|
-
if (!canReuseCurrentState &&
|
|
640
|
+
if (!canReuseCurrentState && isFunction(desensitization)) {
|
|
700
641
|
latestDesensitization = desensitization(latestRowData, latestReactiveParams);
|
|
701
642
|
}
|
|
702
643
|
let latestComponent = canReuseCurrentState ? lastComponent : component || editRender;
|
|
703
|
-
if (!canReuseCurrentState &&
|
|
644
|
+
if (!canReuseCurrentState && isFunction(latestComponent)) {
|
|
704
645
|
latestComponent = latestComponent(latestRowData, latestReactiveParams);
|
|
705
646
|
}
|
|
706
647
|
let latestIsEditable = canReuseCurrentState ? isEditable : column.isEditable ?? true;
|
|
707
|
-
if (!canReuseCurrentState &&
|
|
648
|
+
if (!canReuseCurrentState && isFunction(column.isEditable)) {
|
|
708
649
|
latestIsEditable = column.isEditable(latestRowData, latestReactiveParams);
|
|
709
650
|
}
|
|
710
651
|
let latestValueType = canReuseCurrentState ? lastValueType : valueType;
|
|
711
|
-
if (!canReuseCurrentState &&
|
|
712
|
-
const latestCurrentValue = dataIndex ? latestRowData
|
|
652
|
+
if (!canReuseCurrentState && isFunction(valueType)) {
|
|
653
|
+
const latestCurrentValue = dataIndex ? latestRowData == null ? void 0 : latestRowData[dataIndex] : null;
|
|
713
654
|
latestValueType = valueType(latestCurrentValue, latestRowData, {
|
|
714
655
|
index,
|
|
715
656
|
form,
|
|
716
657
|
namePath: rowNamePath,
|
|
717
|
-
name: column
|
|
658
|
+
name: column == null ? void 0 : column.name
|
|
718
659
|
});
|
|
719
660
|
}
|
|
720
661
|
const latestDisabled = canReuseCurrentState ? lastDisabled : getDisabled({
|
|
721
|
-
globalControl: otherProps
|
|
722
|
-
formDisabled: otherProps
|
|
662
|
+
globalControl: otherProps == null ? void 0 : otherProps.globalControl,
|
|
663
|
+
formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
|
|
723
664
|
column,
|
|
724
|
-
tabledDisabled: config
|
|
665
|
+
tabledDisabled: config == null ? void 0 : config.disabled,
|
|
725
666
|
columnFieldProps: latestFieldProps,
|
|
726
667
|
params: latestRowParams
|
|
727
668
|
});
|
|
728
|
-
|
|
729
|
-
// 更新 componentProps 中的所有响应式属性
|
|
730
|
-
// latestTargetComponent 稍后计算,此处先占位;最终会在下方合并 latestTargetComponent?.props
|
|
731
669
|
let latestComponentProps = {
|
|
732
670
|
...componentProps,
|
|
733
671
|
...latestFieldProps,
|
|
@@ -738,37 +676,28 @@ const RenderField = ({
|
|
|
738
676
|
onBlur: handleBlur
|
|
739
677
|
};
|
|
740
678
|
let latestTargetComponent = canReuseCurrentState ? TargetComponent : fallbackTargetComponent;
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
globalControl: otherProps?.globalControl,
|
|
745
|
-
formDisabled: otherProps?.formDisabled,
|
|
679
|
+
const latestIsView = !latestIsEditable || (record == null ? void 0 : record["is-view"]) || config.isView || virtualKey && !isEditing || getDisabled({
|
|
680
|
+
globalControl: otherProps == null ? void 0 : otherProps.globalControl,
|
|
681
|
+
formDisabled: otherProps == null ? void 0 : otherProps.formDisabled,
|
|
746
682
|
column,
|
|
747
|
-
tabledDisabled: config
|
|
683
|
+
tabledDisabled: config == null ? void 0 : config.disabled,
|
|
748
684
|
columnFieldProps: latestFieldProps,
|
|
749
685
|
params: latestRowParams,
|
|
750
|
-
rowDisabled: rowDisabled ||
|
|
686
|
+
rowDisabled: rowDisabled || "empty"
|
|
751
687
|
});
|
|
752
688
|
if (!canReuseCurrentState && latestIsEditable && isEditing && hasCustomComponent) {
|
|
753
689
|
latestTargetComponent = resolveEditTargetComponent(latestComponent);
|
|
754
690
|
}
|
|
755
|
-
|
|
756
|
-
// 查看模式
|
|
757
691
|
if (!canReuseCurrentState && latestIsView) {
|
|
758
|
-
if (typeof viewRender ===
|
|
759
|
-
const latestCurrentValue = dataIndex ? latestRowData
|
|
692
|
+
if (typeof viewRender === "function") {
|
|
693
|
+
const latestCurrentValue = dataIndex ? latestRowData == null ? void 0 : latestRowData[dataIndex] : value;
|
|
760
694
|
const View = viewRender(latestCurrentValue, latestRowData || {}, options);
|
|
761
|
-
latestTargetComponent =
|
|
762
|
-
viewEmpty: viewEmpty,
|
|
763
|
-
children: View
|
|
764
|
-
});
|
|
695
|
+
latestTargetComponent = /* @__PURE__ */ jsx(Container, { viewEmpty, children: View });
|
|
765
696
|
}
|
|
766
|
-
if (
|
|
697
|
+
if (React.isValidElement(viewRender)) {
|
|
767
698
|
latestTargetComponent = viewRender;
|
|
768
699
|
}
|
|
769
700
|
}
|
|
770
|
-
|
|
771
|
-
// shouldUpdate 触发时外层 componentProps.otherProps.isView 是旧快照,需用最新值覆盖
|
|
772
701
|
latestComponentProps = {
|
|
773
702
|
...latestComponentProps,
|
|
774
703
|
otherProps: {
|
|
@@ -777,13 +706,9 @@ const RenderField = ({
|
|
|
777
706
|
valueType: latestValueType
|
|
778
707
|
}
|
|
779
708
|
};
|
|
780
|
-
|
|
781
|
-
// componentProps 里展开了外层旧 TargetComponent?.props(如 { formType: "Input" }),
|
|
782
|
-
// 用 latestTargetComponent?.props 覆盖,确保不会被旧 cloneElement props 污染
|
|
783
|
-
if ( /*#__PURE__*/React.isValidElement(latestTargetComponent)) {
|
|
709
|
+
if (React.isValidElement(latestTargetComponent)) {
|
|
784
710
|
const elementProps = latestTargetComponent.props;
|
|
785
|
-
|
|
786
|
-
if (elementProps && typeof elementProps === 'object') {
|
|
711
|
+
if (elementProps && typeof elementProps === "object") {
|
|
787
712
|
latestComponentProps = {
|
|
788
713
|
...latestComponentProps,
|
|
789
714
|
...elementProps,
|
|
@@ -802,16 +727,11 @@ const RenderField = ({
|
|
|
802
727
|
effectiveFieldProps: latestFieldProps
|
|
803
728
|
};
|
|
804
729
|
shouldUpdateStateCacheRef.current = {
|
|
805
|
-
rowSnapshot: {
|
|
806
|
-
...latestRowData
|
|
807
|
-
},
|
|
730
|
+
rowSnapshot: { ...latestRowData },
|
|
808
731
|
result
|
|
809
732
|
};
|
|
810
733
|
return result;
|
|
811
734
|
};
|
|
812
|
-
|
|
813
|
-
// 根据 latestIsView 和最新 required/rules 构建正确的 Form.Item props
|
|
814
|
-
// 解决 shouldUpdate 触发时外层 finalFormItemProps 是旧闭包(rules 基于旧 isView 计算)的问题
|
|
815
735
|
const buildActiveFormItemProps = ({
|
|
816
736
|
latestIsView,
|
|
817
737
|
shouldUpdateMode,
|
|
@@ -820,99 +740,82 @@ const RenderField = ({
|
|
|
820
740
|
effectiveFieldProps
|
|
821
741
|
}) => {
|
|
822
742
|
if (latestIsView) {
|
|
823
|
-
|
|
824
|
-
return _omit(finalFormItemProps, ['rules']);
|
|
743
|
+
return omit(finalFormItemProps, ["rules"]);
|
|
825
744
|
}
|
|
826
745
|
if (shouldUpdateMode) {
|
|
827
|
-
// shouldUpdate 模式下 finalFormItemProps 是旧闭包,需用最新 effectiveRequired/effectiveRules 重建 rules
|
|
828
746
|
const activeRules = Array.isArray(effectiveRules) ? [...effectiveRules] : [];
|
|
829
|
-
const hasRequiredRule = activeRules.some(r => r
|
|
747
|
+
const hasRequiredRule = activeRules.some((r) => (r == null ? void 0 : r.required) === true);
|
|
830
748
|
if (effectiveRequired && !hasRequiredRule) {
|
|
831
749
|
const isSelectVal = isSelect({
|
|
832
|
-
dataSource: effectiveFieldProps
|
|
750
|
+
dataSource: effectiveFieldProps == null ? void 0 : effectiveFieldProps.dataSource,
|
|
833
751
|
type
|
|
834
752
|
});
|
|
835
753
|
activeRules.push({
|
|
836
754
|
required: true,
|
|
837
|
-
message: `${isSelectVal ? locale.ProForm.selectPlaceHolder : locale.ProForm.inputPlaceholder}${label ||
|
|
755
|
+
message: `${isSelectVal ? locale.ProForm.selectPlaceHolder : locale.ProForm.inputPlaceholder}${label || ""}`
|
|
838
756
|
});
|
|
839
757
|
}
|
|
840
758
|
return {
|
|
841
759
|
...finalFormItemProps,
|
|
842
|
-
rules: activeRules.length > 0 ? activeRules : [{
|
|
843
|
-
required: false
|
|
844
|
-
}]
|
|
760
|
+
rules: activeRules.length > 0 ? activeRules : [{ required: false }]
|
|
845
761
|
};
|
|
846
762
|
}
|
|
847
763
|
return finalFormItemProps;
|
|
848
764
|
};
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
// 当 viewRender 存在时,需要排除 finalComponentProps 中的 children,避免覆盖 Container 的 children
|
|
853
|
-
let propsForTarget = isView && typeof viewRender === 'function' ? _omit(finalComponentProps, ['children']) : finalComponentProps;
|
|
854
|
-
// 当目标为原生 DOM 元素(如 viewRender 返回 <div>)时,剔除 disabled、toCSTString 等,避免 React 警告
|
|
855
|
-
const isTargetDomElement = /*#__PURE__*/React.isValidElement(TargetComponent) && typeof TargetComponent.type === 'string';
|
|
765
|
+
const assembleFieldComponent = (finalComponentProps) => {
|
|
766
|
+
let propsForTarget = isView && typeof viewRender === "function" ? omit(finalComponentProps, ["children"]) : finalComponentProps;
|
|
767
|
+
const isTargetDomElement = React.isValidElement(TargetComponent) && typeof TargetComponent.type === "string";
|
|
856
768
|
if (isTargetDomElement) {
|
|
857
|
-
propsForTarget =
|
|
769
|
+
propsForTarget = omit(propsForTarget, ["disabled", ...OMIT_FORM_ITEM_AND_DOM_KEYS]);
|
|
858
770
|
}
|
|
859
|
-
// 当 TargetComponent 未定义时,使用空的占位组件避免渲染错误
|
|
860
771
|
let FieldComponent = null;
|
|
861
|
-
if (
|
|
862
|
-
FieldComponent =
|
|
772
|
+
if (React.isValidElement(TargetComponent)) {
|
|
773
|
+
FieldComponent = React.cloneElement(TargetComponent, propsForTarget);
|
|
863
774
|
} else if (TargetComponent) {
|
|
864
|
-
FieldComponent =
|
|
865
|
-
...propsForTarget
|
|
866
|
-
});
|
|
775
|
+
FieldComponent = /* @__PURE__ */ jsx(TargetComponent, { ...propsForTarget });
|
|
867
776
|
} else {
|
|
868
|
-
FieldComponent =
|
|
777
|
+
FieldComponent = /* @__PURE__ */ jsx(Fragment, {});
|
|
869
778
|
}
|
|
870
779
|
if (originalValues && !getIsNew(record)) {
|
|
871
|
-
FieldComponent =
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
780
|
+
FieldComponent = /* @__PURE__ */ jsx(
|
|
781
|
+
ListChangedWrapper,
|
|
782
|
+
{
|
|
783
|
+
name: cellName,
|
|
784
|
+
names,
|
|
785
|
+
namesStr: [...baseName, index, dataIndex],
|
|
786
|
+
rowKeyPath: [...baseName, index, "rowKey"],
|
|
787
|
+
originalName,
|
|
788
|
+
originalNames,
|
|
789
|
+
originalValues,
|
|
790
|
+
form,
|
|
791
|
+
onDiff,
|
|
792
|
+
type,
|
|
793
|
+
onChange: handleChange,
|
|
794
|
+
onBlur: handleBlur,
|
|
795
|
+
valuePropName: finalFormItemProps.valuePropName,
|
|
796
|
+
normalize: finalFormItemProps.normalize,
|
|
797
|
+
getValueProps: finalFormItemProps.getValueProps,
|
|
798
|
+
viewRender,
|
|
799
|
+
diffConfig,
|
|
800
|
+
index,
|
|
801
|
+
children: FieldComponent
|
|
802
|
+
}
|
|
803
|
+
);
|
|
892
804
|
}
|
|
893
|
-
if (finalComponentProps
|
|
894
|
-
FieldComponent =
|
|
895
|
-
...finalComponentProps,
|
|
896
|
-
children: FieldComponent
|
|
897
|
-
});
|
|
805
|
+
if (finalComponentProps == null ? void 0 : finalComponentProps.confirm) {
|
|
806
|
+
FieldComponent = /* @__PURE__ */ jsx(ConfirmWrapper, { ...finalComponentProps, children: FieldComponent });
|
|
898
807
|
}
|
|
899
808
|
return FieldComponent;
|
|
900
809
|
};
|
|
901
|
-
|
|
902
|
-
// 使用useCallback优化getFieldItem函数
|
|
903
810
|
const getFieldItem = (shouldUpdateMode = false) => {
|
|
904
|
-
// 如果处于 shouldUpdate 模式,需要重新获取最新的行数据并重新计算依赖值
|
|
905
811
|
let finalComponentProps = componentProps;
|
|
906
|
-
// shouldUpdate 模式下会被更新为最新值,供外层 FieldProvider 消费
|
|
907
812
|
let latestIsView = isView;
|
|
908
|
-
// 用于在 shouldUpdate 模式下重建正确的 Form.Item rules(外层 finalFormItemProps 是旧闭包)
|
|
909
813
|
let effectiveRequired = lastRequired;
|
|
910
814
|
let effectiveRules = lastRules;
|
|
911
815
|
let effectiveFieldProps = lastFieldProps;
|
|
912
816
|
if (shouldUpdateMode) {
|
|
913
817
|
const recomputed = recalcShouldUpdateState();
|
|
914
818
|
finalComponentProps = recomputed.finalComponentProps;
|
|
915
|
-
// shouldUpdate 模式下用重算结果覆盖外层 TargetComponent,供下方组装逻辑消费
|
|
916
819
|
TargetComponent = recomputed.targetComponent;
|
|
917
820
|
latestIsView = recomputed.latestIsView;
|
|
918
821
|
effectiveRequired = recomputed.effectiveRequired;
|
|
@@ -927,52 +830,52 @@ const RenderField = ({
|
|
|
927
830
|
effectiveFieldProps
|
|
928
831
|
});
|
|
929
832
|
const FieldComponent = assembleFieldComponent(finalComponentProps);
|
|
930
|
-
let FormItem = TargetComponent ?
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
833
|
+
let FormItem = TargetComponent ? /* @__PURE__ */ jsx(
|
|
834
|
+
Form.Item,
|
|
835
|
+
{
|
|
836
|
+
validateFirst: true,
|
|
837
|
+
...omit(activeFinalFormItemProps, [
|
|
838
|
+
"render",
|
|
839
|
+
"key",
|
|
840
|
+
"width",
|
|
841
|
+
"hiddenNames",
|
|
842
|
+
"name",
|
|
843
|
+
"onCell",
|
|
844
|
+
"disabled",
|
|
845
|
+
lastFormItemProps.shouldUpdate ? "shouldUpdate" : null
|
|
846
|
+
]),
|
|
847
|
+
className: cellClassName,
|
|
848
|
+
name: formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName,
|
|
849
|
+
children: FieldComponent
|
|
850
|
+
}
|
|
851
|
+
) : /* @__PURE__ */ jsx(Container, { viewEmpty });
|
|
852
|
+
if (type === "FormList" && !hasCustomComponent && TargetComponent) {
|
|
853
|
+
FormItem = /* @__PURE__ */ jsx(
|
|
854
|
+
Form.List,
|
|
855
|
+
{
|
|
856
|
+
name: formNamePath ? cellName.slice((formNamePath == null ? void 0 : formNamePath.length) - 1) : cellName,
|
|
857
|
+
...omit(activeFinalFormItemProps, ["render", "key", "width", "hiddenNames", "name"]),
|
|
858
|
+
children: (fields, operation, meta) => /* @__PURE__ */ jsx(
|
|
859
|
+
TargetComponent,
|
|
860
|
+
{
|
|
861
|
+
...finalComponentProps,
|
|
862
|
+
otherProps,
|
|
863
|
+
fields,
|
|
864
|
+
operation,
|
|
865
|
+
meta
|
|
866
|
+
}
|
|
867
|
+
)
|
|
868
|
+
}
|
|
869
|
+
);
|
|
952
870
|
}
|
|
953
|
-
// shouldUpdateMode 返回元组,将 latestIsView 暴露给外层用于更新 FieldProvider context
|
|
954
871
|
return shouldUpdateMode ? [FormItem, latestIsView] : FormItem;
|
|
955
872
|
};
|
|
956
|
-
return
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
return /*#__PURE__*/_jsx(FieldProvider, {
|
|
965
|
-
value: {
|
|
966
|
-
...componentProps?.otherProps,
|
|
967
|
-
isView: latestIsView
|
|
968
|
-
},
|
|
969
|
-
children: formItem
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
}) : /*#__PURE__*/_jsx(FieldProvider, {
|
|
973
|
-
value: componentProps?.otherProps || {},
|
|
974
|
-
children: getFieldItem()
|
|
975
|
-
})
|
|
976
|
-
});
|
|
873
|
+
return /* @__PURE__ */ jsx(Fragment, { children: finalFormItemProps.shouldUpdate ? /* @__PURE__ */ jsx(Form.Item, { noStyle: true, shouldUpdate: finalFormItemProps.shouldUpdate, children: () => {
|
|
874
|
+
const [formItem, latestIsView] = getFieldItem(true);
|
|
875
|
+
return /* @__PURE__ */ jsx(FieldProvider, { value: { ...componentProps == null ? void 0 : componentProps.otherProps, isView: latestIsView }, children: formItem });
|
|
876
|
+
} }) : /* @__PURE__ */ jsx(FieldProvider, { value: (componentProps == null ? void 0 : componentProps.otherProps) || {}, children: getFieldItem() }) });
|
|
877
|
+
};
|
|
878
|
+
var RenderField_default = memo(RenderField, arePropsEqual);
|
|
879
|
+
export {
|
|
880
|
+
RenderField_default as default
|
|
977
881
|
};
|
|
978
|
-
export default /*#__PURE__*/memo(RenderField, arePropsEqual);
|