@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
package/es/ProEditTable/index.js
CHANGED
|
@@ -1,33 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef
|
|
9
|
+
} from "react";
|
|
10
|
+
import get from "lodash/get";
|
|
11
|
+
import isArray from "lodash/isArray";
|
|
12
|
+
import isBoolean from "lodash/isBoolean";
|
|
13
|
+
import isFunction from "lodash/isFunction";
|
|
14
|
+
import set from "lodash/set";
|
|
15
|
+
import { useLocalStorageState, useSetState } from "ahooks";
|
|
16
|
+
import { ConfigProvider, Form, Affix } from "antd";
|
|
17
|
+
import { ConfigContext } from "antd/es/config-provider";
|
|
18
|
+
import classnames from "classnames";
|
|
11
19
|
import { transformColumns } from "./utils";
|
|
12
20
|
import { createErrorStore } from "./utils/validateAll";
|
|
13
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
getRandom,
|
|
23
|
+
getNamePath,
|
|
24
|
+
handleScrollToError,
|
|
25
|
+
onPageCheck,
|
|
26
|
+
buildTableRowKey
|
|
27
|
+
} from "./utils/tools";
|
|
14
28
|
import { Validator, Summary, RenderToolbar } from "./components";
|
|
15
29
|
import ProForm from "../ProForm";
|
|
16
30
|
import Empty from "../assets/empty.png";
|
|
17
31
|
import locale, { formatMessage } from "../locale";
|
|
18
32
|
import { BaseTable, DraggableTable } from "./components/RcTable";
|
|
19
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
33
|
const EMPTY_VALUE = [];
|
|
21
34
|
const EMPTY_ACTION_PROPS = [];
|
|
22
35
|
const EMPTY_TOOLBAR_PROPS = [];
|
|
23
|
-
|
|
24
|
-
/** 保留浅层语义相同对象的引用,避免 rest props 每次分配新对象导致整表重算。 */
|
|
25
|
-
const useShallowStableObject = value => {
|
|
36
|
+
const useShallowStableObject = (value) => {
|
|
26
37
|
const valueRef = useRef(value);
|
|
27
38
|
const previous = valueRef.current;
|
|
28
39
|
const previousKeys = Object.keys(previous);
|
|
29
40
|
const nextKeys = Object.keys(value);
|
|
30
|
-
const changed = previousKeys.length !== nextKeys.length || nextKeys.some(key => !Object.is(previous[key], value[key]));
|
|
41
|
+
const changed = previousKeys.length !== nextKeys.length || nextKeys.some((key) => !Object.is(previous[key], value[key]));
|
|
31
42
|
if (changed) {
|
|
32
43
|
valueRef.current = value;
|
|
33
44
|
}
|
|
@@ -40,12 +51,12 @@ const ProEditTable = ({
|
|
|
40
51
|
onDragEnd,
|
|
41
52
|
className,
|
|
42
53
|
columns,
|
|
43
|
-
mode =
|
|
44
|
-
paginationMode =
|
|
54
|
+
mode = "multiple",
|
|
55
|
+
paginationMode = "normal",
|
|
45
56
|
stripe = true,
|
|
46
57
|
draggable = false,
|
|
47
58
|
disabled = false,
|
|
48
|
-
insertType =
|
|
59
|
+
insertType = "after",
|
|
49
60
|
emptyBtnText = locale.ProEditTable.clickAdd,
|
|
50
61
|
actionWidth,
|
|
51
62
|
actionProps = EMPTY_ACTION_PROPS,
|
|
@@ -65,65 +76,64 @@ const ProEditTable = ({
|
|
|
65
76
|
rowDraggable,
|
|
66
77
|
footerRender,
|
|
67
78
|
scroll,
|
|
68
|
-
actionDirection =
|
|
79
|
+
actionDirection = "horizontal",
|
|
69
80
|
diffConfig,
|
|
70
81
|
...resetProps
|
|
71
82
|
}, ref) => {
|
|
83
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
72
84
|
const stableResetProps = useShallowStableObject(resetProps);
|
|
73
|
-
// 上下文form
|
|
74
85
|
const contentForm = Form.useFormInstance();
|
|
75
86
|
const formFieldProps = ProForm.useFieldProps() || {};
|
|
76
87
|
const affixRef = useRef(null);
|
|
77
|
-
const form = contentForm || formFieldProps
|
|
78
|
-
let name = formFieldProps
|
|
79
|
-
const shouldUpdateDebounce = formFieldProps
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
viewEmpty = '-',
|
|
83
|
-
namePath
|
|
84
|
-
} = formFieldProps;
|
|
85
|
-
|
|
86
|
-
// 判断是否在formList内
|
|
87
|
-
if (namePath?.length) {
|
|
88
|
+
const form = contentForm || (formFieldProps == null ? void 0 : formFieldProps.form) || (stableResetProps == null ? void 0 : stableResetProps.form);
|
|
89
|
+
let name = (formFieldProps == null ? void 0 : formFieldProps.name) || (stableResetProps == null ? void 0 : stableResetProps.name) || ((_b = (_a = stableResetProps == null ? void 0 : stableResetProps.id) == null ? void 0 : _a.split) == null ? void 0 : _b.call(_a, "_"));
|
|
90
|
+
const shouldUpdateDebounce = (formFieldProps == null ? void 0 : formFieldProps.shouldUpdateDebounce) ?? (stableResetProps == null ? void 0 : stableResetProps.shouldUpdateDebounce) ?? 200;
|
|
91
|
+
const { isView = false, viewEmpty = "-", namePath } = formFieldProps;
|
|
92
|
+
if (namePath == null ? void 0 : namePath.length) {
|
|
88
93
|
name = [...namePath, ...name.slice(1)];
|
|
89
|
-
disabled = formFieldProps
|
|
94
|
+
disabled = (formFieldProps == null ? void 0 : formFieldProps.disabled) || disabled;
|
|
90
95
|
}
|
|
91
|
-
const nameSignature = Array.isArray(name) ? name.join(
|
|
92
|
-
// ProForm 上下文可能每次渲染都生成新的 namePath 数组,按路径语义稳定引用。
|
|
96
|
+
const nameSignature = Array.isArray(name) ? name.join("") : String(name);
|
|
93
97
|
name = useMemo(() => name, [nameSignature]);
|
|
94
98
|
const tableRef = useRef(null);
|
|
95
|
-
|
|
96
|
-
// 解决滚动卸载后报错丢失(报错常驻)。按表格实例隔离。
|
|
97
|
-
const errorStoreRef = useRef(undefined);
|
|
99
|
+
const errorStoreRef = useRef(void 0);
|
|
98
100
|
if (!errorStoreRef.current) {
|
|
99
101
|
errorStoreRef.current = createErrorStore();
|
|
100
102
|
}
|
|
101
|
-
// shouldCellUpdate 缓存按表格实例隔离,避免 module-level Map 在多实例间交叉污染
|
|
102
103
|
const cellCachesRef = useRef({
|
|
103
|
-
dataSourceRef: new Map(),
|
|
104
|
-
componentRef: new Map(),
|
|
105
|
-
listLength: new Map()
|
|
104
|
+
dataSourceRef: /* @__PURE__ */ new Map(),
|
|
105
|
+
componentRef: /* @__PURE__ */ new Map(),
|
|
106
|
+
listLength: /* @__PURE__ */ new Map()
|
|
106
107
|
});
|
|
107
|
-
|
|
108
|
-
// valueChangeRef.current = 0;
|
|
109
|
-
|
|
110
|
-
const {
|
|
111
|
-
getPrefixCls
|
|
112
|
-
} = React.useContext(ConfigContext);
|
|
108
|
+
const { getPrefixCls } = React.useContext(ConfigContext);
|
|
113
109
|
const prefixCls = getPrefixCls();
|
|
114
|
-
const [themeConfig] = useLocalStorageState(
|
|
110
|
+
const [themeConfig] = useLocalStorageState("themeConfig");
|
|
115
111
|
const requiredAlign = useMemo(() => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
112
|
+
var _a2;
|
|
113
|
+
return ((_a2 = themeConfig == null ? void 0 : themeConfig.data) == null ? void 0 : _a2.zauiFormAlign) ?? configRequiredAlign ?? "left";
|
|
114
|
+
}, [(_c = themeConfig == null ? void 0 : themeConfig.data) == null ? void 0 : _c.zauiFormAlign, configRequiredAlign]);
|
|
115
|
+
const renderOtherProps = useMemo(
|
|
116
|
+
() => {
|
|
117
|
+
var _a2, _b2, _c2;
|
|
118
|
+
return {
|
|
119
|
+
globalControl: (_a2 = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _a2.globalControl,
|
|
120
|
+
formDisabled: (_b2 = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _b2.formDisabled,
|
|
121
|
+
desensitizationKey: (_c2 = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _c2.desensitizationKey
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
[
|
|
125
|
+
(_d = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _d.desensitizationKey,
|
|
126
|
+
(_e = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _e.formDisabled,
|
|
127
|
+
(_f = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _f.globalControl
|
|
128
|
+
]
|
|
129
|
+
);
|
|
130
|
+
const mergedDiffConfig = useMemo(
|
|
131
|
+
() => {
|
|
132
|
+
var _a2;
|
|
133
|
+
return { ...(_a2 = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _a2.diffConfig, ...diffConfig };
|
|
134
|
+
},
|
|
135
|
+
[diffConfig, (_g = stableResetProps == null ? void 0 : stableResetProps.otherProps) == null ? void 0 : _g.diffConfig]
|
|
136
|
+
);
|
|
127
137
|
const [state, setState] = useSetState({
|
|
128
138
|
forceUpdate: {},
|
|
129
139
|
// 表格内部强制刷新开关
|
|
@@ -133,223 +143,275 @@ const ProEditTable = ({
|
|
|
133
143
|
// 当前选中行的row-key集合
|
|
134
144
|
selectedRows: [],
|
|
135
145
|
// 当前选中行的row-key集合
|
|
136
|
-
virtualKey: mode ===
|
|
146
|
+
virtualKey: mode === "single" ? getRandom() : "",
|
|
137
147
|
// 单行编辑生成个随机formItem的key
|
|
138
148
|
page: {
|
|
139
149
|
pageNum: 1,
|
|
140
|
-
pageSize: pagination
|
|
150
|
+
pageSize: (pagination == null ? void 0 : pagination.pageSize) || 10
|
|
141
151
|
}
|
|
142
152
|
});
|
|
143
|
-
const {
|
|
144
|
-
forceUpdate,
|
|
145
|
-
editingKeys,
|
|
146
|
-
virtualKey,
|
|
147
|
-
selectedRowKeys,
|
|
148
|
-
selectedRows,
|
|
149
|
-
page
|
|
150
|
-
} = state;
|
|
153
|
+
const { forceUpdate, editingKeys, virtualKey, selectedRowKeys, selectedRows, page } = state;
|
|
151
154
|
const paginationEnabled = Boolean(pagination);
|
|
152
|
-
const paginationValidationEnabled = paginationEnabled && paginationMode ===
|
|
153
|
-
const paginationConfig = typeof pagination ===
|
|
154
|
-
const resolvedPage = useMemo(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
const paginationValidationEnabled = paginationEnabled && paginationMode === "validate";
|
|
156
|
+
const paginationConfig = typeof pagination === "object" ? pagination : void 0;
|
|
157
|
+
const resolvedPage = useMemo(
|
|
158
|
+
() => ({
|
|
159
|
+
pageNum: (paginationConfig == null ? void 0 : paginationConfig.current) ?? page.pageNum,
|
|
160
|
+
pageSize: (paginationConfig == null ? void 0 : paginationConfig.pageSize) ?? page.pageSize
|
|
161
|
+
}),
|
|
162
|
+
[page.pageNum, page.pageSize, paginationConfig == null ? void 0 : paginationConfig.current, paginationConfig == null ? void 0 : paginationConfig.pageSize]
|
|
163
|
+
);
|
|
164
|
+
const mergedSelectedRowKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) ?? selectedRowKeys;
|
|
165
|
+
const virtualRowName = useMemo(
|
|
166
|
+
() => getNamePath(isArray(name) ? name : [name], virtualKey),
|
|
167
|
+
[name, virtualKey]
|
|
168
|
+
);
|
|
162
169
|
const _className = classnames({
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
"pro-edit-table": true,
|
|
171
|
+
"pro-edit-table-drag": draggable,
|
|
172
|
+
"pro-table-no-stripe": !stripe,
|
|
166
173
|
className
|
|
167
174
|
});
|
|
168
|
-
const getRowKey = useCallback(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
const getRowKey = useCallback(
|
|
176
|
+
(record) => {
|
|
177
|
+
let key = record.rowKey || getRandom();
|
|
178
|
+
if (rowKey) {
|
|
179
|
+
const userKey = isFunction(rowKey) ? rowKey(record) : record[rowKey];
|
|
180
|
+
if (userKey != null && !Number.isNaN(userKey) && userKey !== "") {
|
|
181
|
+
key = userKey;
|
|
182
|
+
}
|
|
175
183
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
184
|
+
return String(key);
|
|
185
|
+
},
|
|
186
|
+
[rowKey]
|
|
187
|
+
);
|
|
179
188
|
const originalValues = useMemo(() => {
|
|
189
|
+
var _a2, _b2, _c2;
|
|
180
190
|
let nextOriginalValues;
|
|
181
|
-
|
|
182
|
-
const originalArr =
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (originalArr?.length && (!isOriginalAllHasKey || isNeedCoverOriginal)) {
|
|
187
|
-
originalArr?.forEach?.(item => {
|
|
191
|
+
const originalArr = get(stableResetProps == null ? void 0 : stableResetProps.originalValues, name);
|
|
192
|
+
const isOriginalAllHasKey = originalArr ? (_a2 = originalArr == null ? void 0 : originalArr.every) == null ? void 0 : _a2.call(originalArr, (item) => item.rowKey) : true;
|
|
193
|
+
const isNeedCoverOriginal = (_b2 = originalArr == null ? void 0 : originalArr.some) == null ? void 0 : _b2.call(originalArr, (item) => item.rowKey !== getRowKey(item));
|
|
194
|
+
if ((originalArr == null ? void 0 : originalArr.length) && (!isOriginalAllHasKey || isNeedCoverOriginal)) {
|
|
195
|
+
(_c2 = originalArr == null ? void 0 : originalArr.forEach) == null ? void 0 : _c2.call(originalArr, (item) => {
|
|
188
196
|
item.rowKey = getRowKey(item);
|
|
189
197
|
});
|
|
190
198
|
}
|
|
191
|
-
if (originalArr
|
|
199
|
+
if (originalArr == null ? void 0 : originalArr.length) {
|
|
192
200
|
nextOriginalValues = {};
|
|
193
|
-
|
|
201
|
+
set(nextOriginalValues, name, originalArr);
|
|
194
202
|
}
|
|
195
203
|
return nextOriginalValues;
|
|
196
|
-
}, [getRowKey, name, stableResetProps
|
|
197
|
-
const getIsNew = useCallback(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
recursive: true
|
|
213
|
-
});
|
|
214
|
-
} catch (error) {
|
|
215
|
-
handleScrollToError();
|
|
204
|
+
}, [getRowKey, name, stableResetProps == null ? void 0 : stableResetProps.originalValues]);
|
|
205
|
+
const getIsNew = useCallback(
|
|
206
|
+
(record) => {
|
|
207
|
+
var _a2;
|
|
208
|
+
const originalArr = get(originalValues, name);
|
|
209
|
+
if (!(originalArr == null ? void 0 : originalArr.length)) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
return !((_a2 = originalArr == null ? void 0 : originalArr.find) == null ? void 0 : _a2.call(originalArr, (item) => getRowKey(item) === getRowKey(record)));
|
|
213
|
+
},
|
|
214
|
+
[getRowKey, originalValues, name]
|
|
215
|
+
);
|
|
216
|
+
const handlePageChange = useCallback(
|
|
217
|
+
async (current, pageSize) => {
|
|
218
|
+
var _a2;
|
|
219
|
+
if (!paginationEnabled)
|
|
216
220
|
return;
|
|
221
|
+
const isPageSizeChange = pageSize !== resolvedPage.pageSize;
|
|
222
|
+
if (paginationValidationEnabled && !isPageSizeChange) {
|
|
223
|
+
try {
|
|
224
|
+
await form.validateFields([name], { recursive: true });
|
|
225
|
+
} catch (error) {
|
|
226
|
+
handleScrollToError();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
217
229
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
setState({
|
|
231
|
+
page: {
|
|
232
|
+
pageNum: current,
|
|
233
|
+
pageSize: pageSize ?? resolvedPage.pageSize
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
(_a2 = paginationConfig == null ? void 0 : paginationConfig.onChange) == null ? void 0 : _a2.call(paginationConfig, current, pageSize);
|
|
237
|
+
},
|
|
238
|
+
[
|
|
239
|
+
form,
|
|
240
|
+
name,
|
|
241
|
+
paginationConfig == null ? void 0 : paginationConfig.onChange,
|
|
242
|
+
paginationEnabled,
|
|
243
|
+
paginationValidationEnabled,
|
|
244
|
+
resolvedPage.pageSize
|
|
245
|
+
]
|
|
246
|
+
);
|
|
247
|
+
const config = useMemo(
|
|
248
|
+
() => ({
|
|
249
|
+
form,
|
|
250
|
+
mode,
|
|
251
|
+
isView,
|
|
252
|
+
viewEmpty,
|
|
253
|
+
disabled,
|
|
254
|
+
forceUpdate,
|
|
255
|
+
insertType,
|
|
256
|
+
emptyBtnText,
|
|
257
|
+
editingKeys,
|
|
258
|
+
actionWidth,
|
|
259
|
+
actionProps,
|
|
260
|
+
toolbarProps,
|
|
261
|
+
setState,
|
|
262
|
+
selectedRowKeys: mergedSelectedRowKeys,
|
|
263
|
+
selectedRows,
|
|
264
|
+
onlyOneLineMsg,
|
|
265
|
+
deletePoConfirmMsg,
|
|
266
|
+
mulDeletePoConfirmMsg,
|
|
267
|
+
virtualKey,
|
|
268
|
+
requiredAlign,
|
|
269
|
+
name: isArray(name) ? name : [name],
|
|
270
|
+
// name需要处理成namePath形式,为兼容多路径
|
|
271
|
+
namePath,
|
|
272
|
+
columns,
|
|
273
|
+
// 原始列配置:供单元格变更后按所属列(含 names 合并名)重校验/清理常驻报错
|
|
274
|
+
tableRef,
|
|
275
|
+
max,
|
|
276
|
+
tableLength: value == null ? void 0 : value.length,
|
|
277
|
+
page: resolvedPage,
|
|
278
|
+
originalValues,
|
|
279
|
+
errorStore: errorStoreRef.current,
|
|
280
|
+
prefixCls,
|
|
281
|
+
rowDisabled,
|
|
282
|
+
actionDirection,
|
|
283
|
+
diffConfig: mergedDiffConfig,
|
|
284
|
+
shouldUpdateDebounce,
|
|
285
|
+
getIsNew,
|
|
286
|
+
handlePageChange,
|
|
287
|
+
validateTrigger: stableResetProps == null ? void 0 : stableResetProps.validateTrigger,
|
|
288
|
+
validateMessages: stableResetProps == null ? void 0 : stableResetProps.validateMessages,
|
|
289
|
+
virtual: stableResetProps == null ? void 0 : stableResetProps.virtual,
|
|
290
|
+
otherProps: renderOtherProps
|
|
291
|
+
}),
|
|
292
|
+
[
|
|
293
|
+
actionDirection,
|
|
294
|
+
actionProps,
|
|
295
|
+
actionWidth,
|
|
296
|
+
columns,
|
|
297
|
+
deletePoConfirmMsg,
|
|
298
|
+
diffConfig,
|
|
299
|
+
editingKeys,
|
|
300
|
+
emptyBtnText,
|
|
301
|
+
form,
|
|
302
|
+
// forceUpdate 不应该作为依赖项,因为它是触发刷新的信号,而非用于比较的数据
|
|
303
|
+
getIsNew,
|
|
304
|
+
handlePageChange,
|
|
305
|
+
insertType,
|
|
306
|
+
isView,
|
|
307
|
+
max,
|
|
308
|
+
mergedDiffConfig,
|
|
309
|
+
mode,
|
|
310
|
+
mulDeletePoConfirmMsg,
|
|
311
|
+
name,
|
|
312
|
+
namePath,
|
|
313
|
+
onlyOneLineMsg,
|
|
314
|
+
originalValues,
|
|
315
|
+
prefixCls,
|
|
316
|
+
requiredAlign,
|
|
317
|
+
renderOtherProps,
|
|
318
|
+
rowDisabled,
|
|
319
|
+
mergedSelectedRowKeys,
|
|
320
|
+
selectedRows,
|
|
321
|
+
shouldUpdateDebounce,
|
|
322
|
+
stableResetProps == null ? void 0 : stableResetProps.validateMessages,
|
|
323
|
+
stableResetProps == null ? void 0 : stableResetProps.validateTrigger,
|
|
324
|
+
stableResetProps == null ? void 0 : stableResetProps.virtual,
|
|
325
|
+
tableRef,
|
|
326
|
+
toolbarProps,
|
|
327
|
+
value == null ? void 0 : value.length,
|
|
328
|
+
viewEmpty,
|
|
329
|
+
virtualKey,
|
|
330
|
+
resolvedPage
|
|
331
|
+
]
|
|
332
|
+
);
|
|
333
|
+
const _rowClassName = useCallback(
|
|
334
|
+
(record) => {
|
|
335
|
+
const isEdit = !virtualKey || editingKeys.includes(record.rowKey);
|
|
336
|
+
const rowClassName = isEdit ? "is-editing" : "";
|
|
337
|
+
if (getIsNew(record)) {
|
|
338
|
+
return `is-new-row ${rowClassName}`;
|
|
223
339
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
disabled,
|
|
233
|
-
forceUpdate,
|
|
234
|
-
insertType,
|
|
235
|
-
emptyBtnText,
|
|
236
|
-
editingKeys,
|
|
237
|
-
actionWidth,
|
|
238
|
-
actionProps,
|
|
239
|
-
toolbarProps,
|
|
240
|
-
setState,
|
|
241
|
-
selectedRowKeys: mergedSelectedRowKeys,
|
|
242
|
-
selectedRows,
|
|
243
|
-
onlyOneLineMsg,
|
|
244
|
-
deletePoConfirmMsg,
|
|
245
|
-
mulDeletePoConfirmMsg,
|
|
246
|
-
virtualKey,
|
|
247
|
-
requiredAlign,
|
|
248
|
-
name: _isArray(name) ? name : [name],
|
|
249
|
-
// name需要处理成namePath形式,为兼容多路径
|
|
250
|
-
namePath,
|
|
251
|
-
columns,
|
|
252
|
-
// 原始列配置:供单元格变更后按所属列(含 names 合并名)重校验/清理常驻报错
|
|
253
|
-
tableRef,
|
|
254
|
-
max,
|
|
255
|
-
tableLength: value?.length,
|
|
256
|
-
page: resolvedPage,
|
|
257
|
-
originalValues,
|
|
258
|
-
errorStore: errorStoreRef.current,
|
|
259
|
-
prefixCls,
|
|
260
|
-
rowDisabled,
|
|
261
|
-
actionDirection,
|
|
262
|
-
diffConfig: mergedDiffConfig,
|
|
263
|
-
shouldUpdateDebounce,
|
|
264
|
-
getIsNew,
|
|
265
|
-
handlePageChange,
|
|
266
|
-
validateTrigger: stableResetProps?.validateTrigger,
|
|
267
|
-
validateMessages: stableResetProps?.validateMessages,
|
|
268
|
-
virtual: stableResetProps?.virtual,
|
|
269
|
-
otherProps: renderOtherProps
|
|
270
|
-
}), [actionDirection, actionProps, actionWidth, columns, deletePoConfirmMsg, diffConfig, editingKeys, emptyBtnText, form,
|
|
271
|
-
// forceUpdate 不应该作为依赖项,因为它是触发刷新的信号,而非用于比较的数据
|
|
272
|
-
getIsNew, handlePageChange, insertType, isView, max, mergedDiffConfig, mode, mulDeletePoConfirmMsg, name, namePath, onlyOneLineMsg, originalValues, prefixCls, requiredAlign, renderOtherProps, rowDisabled, mergedSelectedRowKeys, selectedRows, shouldUpdateDebounce, stableResetProps?.validateMessages, stableResetProps?.validateTrigger, stableResetProps?.virtual, tableRef, toolbarProps, value?.length, viewEmpty, virtualKey, resolvedPage]);
|
|
273
|
-
|
|
274
|
-
// 编辑行设置下样式
|
|
275
|
-
const _rowClassName = useCallback(record => {
|
|
276
|
-
const isEdit = !virtualKey || editingKeys.includes(record.rowKey);
|
|
277
|
-
const rowClassName = isEdit ? 'is-editing' : '';
|
|
278
|
-
if (getIsNew(record)) {
|
|
279
|
-
return `is-new-row ${rowClassName}`;
|
|
280
|
-
}
|
|
281
|
-
return rowClassName;
|
|
282
|
-
}, [editingKeys, getIsNew, virtualKey]);
|
|
283
|
-
|
|
284
|
-
// 判断是否禁止添加、批量删除
|
|
285
|
-
const isForbiddenBtn = useCallback(type => {
|
|
286
|
-
// 当工具栏不渲染时,都不渲染
|
|
287
|
-
if (toolbarProps === false) {
|
|
288
|
-
return true;
|
|
289
|
-
}
|
|
290
|
-
// 通过配置项配置show 为 false 开启关闭添加与批量删除
|
|
291
|
-
if (Array.isArray(toolbarProps)) {
|
|
292
|
-
const addBtnConfig = toolbarProps?.find(item => item.type === type);
|
|
293
|
-
if (_isFunction(addBtnConfig?.show)) {
|
|
294
|
-
const result = addBtnConfig.show();
|
|
295
|
-
addBtnConfig.show = result;
|
|
340
|
+
return rowClassName;
|
|
341
|
+
},
|
|
342
|
+
[editingKeys, getIsNew, virtualKey]
|
|
343
|
+
);
|
|
344
|
+
const isForbiddenBtn = useCallback(
|
|
345
|
+
(type) => {
|
|
346
|
+
if (toolbarProps === false) {
|
|
347
|
+
return true;
|
|
296
348
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// 复选框
|
|
306
|
-
const _rowSelection = useMemo(() => ({
|
|
307
|
-
fixed: true,
|
|
308
|
-
columnWidth: 48,
|
|
309
|
-
getCheckboxProps: record => {
|
|
310
|
-
if (rowDisabled) {
|
|
311
|
-
const _disabled = rowDisabled(record);
|
|
312
|
-
return {
|
|
313
|
-
disabled: _disabled
|
|
314
|
-
};
|
|
349
|
+
if (Array.isArray(toolbarProps)) {
|
|
350
|
+
const addBtnConfig = toolbarProps == null ? void 0 : toolbarProps.find((item) => item.type === type);
|
|
351
|
+
if (isFunction(addBtnConfig == null ? void 0 : addBtnConfig.show)) {
|
|
352
|
+
const result = addBtnConfig.show();
|
|
353
|
+
addBtnConfig.show = result;
|
|
354
|
+
}
|
|
355
|
+
return (addBtnConfig == null ? void 0 : addBtnConfig.show) === false;
|
|
315
356
|
}
|
|
316
|
-
return
|
|
357
|
+
return false;
|
|
317
358
|
},
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
359
|
+
[toolbarProps]
|
|
360
|
+
);
|
|
361
|
+
const isHideCheckBox = !rowSelection && isForbiddenBtn("mulDelete");
|
|
362
|
+
const _rowSelection = useMemo(
|
|
363
|
+
() => ({
|
|
364
|
+
fixed: true,
|
|
365
|
+
columnWidth: 48,
|
|
366
|
+
getCheckboxProps: (record) => {
|
|
367
|
+
if (rowDisabled) {
|
|
368
|
+
const _disabled = rowDisabled(record);
|
|
369
|
+
return {
|
|
370
|
+
disabled: _disabled
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
return {};
|
|
374
|
+
},
|
|
375
|
+
hideSelectAll: isHideCheckBox,
|
|
376
|
+
...rowSelection,
|
|
377
|
+
selectedRowKeys: mergedSelectedRowKeys,
|
|
378
|
+
onChange: (nextSelectedRowKeys, nextSelectedRows, info) => {
|
|
379
|
+
var _a2;
|
|
380
|
+
setState({
|
|
381
|
+
selectedRowKeys: nextSelectedRowKeys,
|
|
382
|
+
selectedRows: nextSelectedRows
|
|
383
|
+
});
|
|
384
|
+
(_a2 = rowSelection == null ? void 0 : rowSelection.onChange) == null ? void 0 : _a2.call(rowSelection, nextSelectedRowKeys, nextSelectedRows, info);
|
|
385
|
+
}
|
|
386
|
+
}),
|
|
387
|
+
[isHideCheckBox, mergedSelectedRowKeys, rowDisabled, rowSelection, setState]
|
|
388
|
+
);
|
|
389
|
+
const emptyDom = useMemo(
|
|
390
|
+
() => () => {
|
|
391
|
+
var _a2;
|
|
392
|
+
return /* @__PURE__ */ jsxs("div", { className: "com-empty", children: [
|
|
393
|
+
/* @__PURE__ */ jsx("img", { className: "img", src: Empty, alt: "Empty" }),
|
|
394
|
+
/* @__PURE__ */ jsx("div", { className: "content", children: disabled || isForbiddenBtn("add") ? locale.ProEditTable.noData : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
395
|
+
locale.ProEditTable.noData,
|
|
396
|
+
",",
|
|
397
|
+
/* @__PURE__ */ jsx(
|
|
398
|
+
RenderToolbar,
|
|
399
|
+
{
|
|
400
|
+
...{
|
|
401
|
+
...config,
|
|
402
|
+
toolbarProps: (_a2 = toolbarProps == null ? void 0 : toolbarProps.filter) == null ? void 0 : _a2.call(
|
|
403
|
+
toolbarProps,
|
|
404
|
+
(item) => item.type === "add" || (item == null ? void 0 : item.persistence)
|
|
405
|
+
),
|
|
406
|
+
dataSource: []
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
] }) })
|
|
411
|
+
] });
|
|
412
|
+
},
|
|
413
|
+
[config, disabled, isForbiddenBtn, toolbarProps]
|
|
414
|
+
);
|
|
353
415
|
const renderRowSelection = useCallback(() => {
|
|
354
416
|
if (disabled || isView) {
|
|
355
417
|
return null;
|
|
@@ -366,20 +428,20 @@ const ProEditTable = ({
|
|
|
366
428
|
return transformColumns(columns, config, cellCachesRef.current);
|
|
367
429
|
}, [columns, config, forceUpdate]);
|
|
368
430
|
const initDataSource = () => {
|
|
369
|
-
|
|
370
|
-
const isAllHasKey =
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (value
|
|
376
|
-
const nextValues = value
|
|
431
|
+
var _a2, _b2;
|
|
432
|
+
const isAllHasKey = (_a2 = value == null ? void 0 : value.every) == null ? void 0 : _a2.call(
|
|
433
|
+
value,
|
|
434
|
+
(item) => item.rowKey || typeof rowKey === "string" && item[rowKey]
|
|
435
|
+
);
|
|
436
|
+
const isNeedCover = (_b2 = value == null ? void 0 : value.some) == null ? void 0 : _b2.call(value, (item) => item.rowKey !== (getRowKey == null ? void 0 : getRowKey(item)));
|
|
437
|
+
if ((value == null ? void 0 : value.length) && (!isAllHasKey || isNeedCover)) {
|
|
438
|
+
const nextValues = value == null ? void 0 : value.map((item) => {
|
|
377
439
|
return {
|
|
378
440
|
...item,
|
|
379
441
|
rowKey: getRowKey(item)
|
|
380
442
|
};
|
|
381
443
|
});
|
|
382
|
-
onChange
|
|
444
|
+
onChange == null ? void 0 : onChange(nextValues);
|
|
383
445
|
if (virtualKey) {
|
|
384
446
|
form.setFieldValue(virtualRowName, nextValues);
|
|
385
447
|
}
|
|
@@ -388,7 +450,7 @@ const ProEditTable = ({
|
|
|
388
450
|
useEffect(() => {
|
|
389
451
|
initDataSource();
|
|
390
452
|
}, [value, originalValues]);
|
|
391
|
-
useImperativeHandle(stableResetProps
|
|
453
|
+
useImperativeHandle((stableResetProps == null ? void 0 : stableResetProps.ref) || ref, () => {
|
|
392
454
|
return {
|
|
393
455
|
getInternalState: () => state,
|
|
394
456
|
setInternalState: setState
|
|
@@ -397,132 +459,148 @@ const ProEditTable = ({
|
|
|
397
459
|
useEffect(() => {
|
|
398
460
|
if (toolbarSticky) {
|
|
399
461
|
const updatePos = () => {
|
|
400
|
-
|
|
462
|
+
var _a2, _b2;
|
|
463
|
+
(_b2 = (_a2 = affixRef == null ? void 0 : affixRef.current) == null ? void 0 : _a2.updatePosition) == null ? void 0 : _b2.call(_a2);
|
|
401
464
|
};
|
|
402
|
-
window.addEventListener(
|
|
465
|
+
window.addEventListener("scroll", updatePos, true);
|
|
403
466
|
return () => {
|
|
404
|
-
window.removeEventListener(
|
|
467
|
+
window.removeEventListener("scroll", updatePos, true);
|
|
405
468
|
};
|
|
406
469
|
}
|
|
407
470
|
}, [toolbarSticky]);
|
|
408
|
-
const _toolbarSticky =
|
|
409
|
-
const _summary = useMemo(
|
|
410
|
-
data
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}) : summary, [renderRowSelection, summary]);
|
|
471
|
+
const _toolbarSticky = isBoolean(toolbarSticky) ? {} : toolbarSticky;
|
|
472
|
+
const _summary = useMemo(
|
|
473
|
+
() => typeof summary === "object" ? (data) => /* @__PURE__ */ jsx(Summary, { data, summary, rowSelection: renderRowSelection() }) : summary,
|
|
474
|
+
[renderRowSelection, summary]
|
|
475
|
+
);
|
|
414
476
|
const TableComponent = draggable ? DraggableTable : BaseTable;
|
|
415
|
-
|
|
416
|
-
// 给每个 record 附加编辑状态标识,让 shouldCellUpdate 能检测到状态变化
|
|
417
|
-
// 始终注入 _rowIndex,供 shouldCellUpdate 感知行位置变化(增删行后同一行数据不变但位置变了)
|
|
418
|
-
// draggable 时同时注入 _dragIndex
|
|
419
477
|
const enrichedValue = useMemo(() => {
|
|
420
|
-
return value
|
|
478
|
+
return value == null ? void 0 : value.map((record, idx) => ({
|
|
421
479
|
...record,
|
|
422
|
-
...
|
|
423
|
-
|
|
424
|
-
} : {}),
|
|
425
|
-
...(draggable ? {
|
|
426
|
-
_dragIndex: idx
|
|
427
|
-
} : {}),
|
|
480
|
+
...virtualKey ? { _isEditing: editingKeys.includes(record.rowKey) || record._addFlag } : {},
|
|
481
|
+
...draggable ? { _dragIndex: idx } : {},
|
|
428
482
|
_rowIndex: idx
|
|
429
483
|
}));
|
|
430
484
|
}, [value, virtualKey, editingKeys, draggable]);
|
|
431
485
|
const tableRowKey = useMemo(() => buildTableRowKey(rowKey), [rowKey]);
|
|
432
|
-
const tableProps = useMemo(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
})
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
columns,
|
|
506
|
-
page: resolvedPage,
|
|
507
|
-
pagination,
|
|
508
|
-
isView,
|
|
509
|
-
disabled,
|
|
510
|
-
setState
|
|
511
|
-
});
|
|
486
|
+
const tableProps = useMemo(
|
|
487
|
+
() => ({
|
|
488
|
+
rowKey,
|
|
489
|
+
tableRowKey,
|
|
490
|
+
value: enrichedValue,
|
|
491
|
+
headerRender,
|
|
492
|
+
tableRef,
|
|
493
|
+
className: _className,
|
|
494
|
+
columns: _columns,
|
|
495
|
+
renderRowSelection,
|
|
496
|
+
rowClassName: _rowClassName,
|
|
497
|
+
disabled,
|
|
498
|
+
virtualKey,
|
|
499
|
+
editingKeys,
|
|
500
|
+
isHideCheckBox,
|
|
501
|
+
rowDraggable,
|
|
502
|
+
pagination,
|
|
503
|
+
paginationValidationEnabled,
|
|
504
|
+
scroll,
|
|
505
|
+
summary: _summary,
|
|
506
|
+
page: resolvedPage,
|
|
507
|
+
formatMessage,
|
|
508
|
+
locale,
|
|
509
|
+
handlePageChange
|
|
510
|
+
}),
|
|
511
|
+
[
|
|
512
|
+
_className,
|
|
513
|
+
_columns,
|
|
514
|
+
_rowClassName,
|
|
515
|
+
disabled,
|
|
516
|
+
editingKeys,
|
|
517
|
+
formatMessage,
|
|
518
|
+
handlePageChange,
|
|
519
|
+
headerRender,
|
|
520
|
+
isHideCheckBox,
|
|
521
|
+
locale,
|
|
522
|
+
pagination,
|
|
523
|
+
paginationValidationEnabled,
|
|
524
|
+
renderRowSelection,
|
|
525
|
+
rowDraggable,
|
|
526
|
+
rowKey,
|
|
527
|
+
tableRowKey,
|
|
528
|
+
scroll,
|
|
529
|
+
_summary,
|
|
530
|
+
tableRef,
|
|
531
|
+
enrichedValue,
|
|
532
|
+
resolvedPage,
|
|
533
|
+
virtualKey
|
|
534
|
+
]
|
|
535
|
+
);
|
|
536
|
+
const handleDragChange = useCallback(
|
|
537
|
+
(newValue) => {
|
|
538
|
+
const cleanValue = newValue == null ? void 0 : newValue.map(({ _dragIndex: _d2, _rowIndex: _r, ...rest }) => rest);
|
|
539
|
+
onChange == null ? void 0 : onChange(cleanValue);
|
|
540
|
+
},
|
|
541
|
+
[onChange]
|
|
542
|
+
);
|
|
543
|
+
const draggableProps = useMemo(
|
|
544
|
+
() => ({
|
|
545
|
+
onChange: draggable ? handleDragChange : onChange,
|
|
546
|
+
onDrag,
|
|
547
|
+
onDragEnd,
|
|
548
|
+
draggable
|
|
549
|
+
}),
|
|
550
|
+
[draggable, handleDragChange, onChange, onDrag, onDragEnd]
|
|
551
|
+
);
|
|
552
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
553
|
+
/* @__PURE__ */ jsx(ConfigProvider, { renderEmpty: (value == null ? void 0 : value.length) ? void 0 : emptyDom, children: /* @__PURE__ */ jsx(TableComponent, { ...resetProps, draggableProps, tableProps }) }),
|
|
554
|
+
!isView && (value == null ? void 0 : value.length) ? toolbarSticky ? /* @__PURE__ */ jsx(Affix, { ref: affixRef, ..._toolbarSticky, children: /* @__PURE__ */ jsx(
|
|
555
|
+
"div",
|
|
556
|
+
{
|
|
557
|
+
className: `pro-edit-table-toolbar${paginationEnabled ? " pro-edit-table-toolbar-fixed" : ""}`,
|
|
558
|
+
children: /* @__PURE__ */ jsx(RenderToolbar, { ...config })
|
|
512
559
|
}
|
|
513
|
-
}) :
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
560
|
+
) }) : /* @__PURE__ */ jsx(
|
|
561
|
+
"div",
|
|
562
|
+
{
|
|
563
|
+
className: `pro-edit-table-toolbar${paginationEnabled ? " pro-edit-table-toolbar-fixed" : ""}`,
|
|
564
|
+
children: /* @__PURE__ */ jsx(RenderToolbar, { ...config })
|
|
565
|
+
}
|
|
566
|
+
) : null,
|
|
567
|
+
footerRender ? /* @__PURE__ */ jsx("div", { className: "pro-edit-table-footer", children: footerRender }) : null,
|
|
568
|
+
paginationValidationEnabled ? /* @__PURE__ */ jsx(
|
|
569
|
+
"div",
|
|
570
|
+
{
|
|
571
|
+
id: `pro-edit-table-pagination-${Array.isArray(config.name) ? config.name.filter(Boolean).join("-") : config.name || "default"}`,
|
|
572
|
+
onClick: () => {
|
|
573
|
+
onPageCheck({
|
|
574
|
+
form,
|
|
575
|
+
name,
|
|
576
|
+
value,
|
|
577
|
+
columns,
|
|
578
|
+
page: resolvedPage,
|
|
579
|
+
pagination,
|
|
580
|
+
isView,
|
|
581
|
+
disabled,
|
|
582
|
+
setState
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
) : null,
|
|
587
|
+
/* @__PURE__ */ jsx(
|
|
588
|
+
Validator,
|
|
589
|
+
{
|
|
590
|
+
name,
|
|
591
|
+
virtualKey,
|
|
592
|
+
editingKeys,
|
|
593
|
+
onlyOneLineMsg,
|
|
594
|
+
virtual: stableResetProps == null ? void 0 : stableResetProps.virtual,
|
|
595
|
+
columns,
|
|
596
|
+
config,
|
|
597
|
+
errorStore: errorStoreRef.current
|
|
598
|
+
}
|
|
599
|
+
)
|
|
600
|
+
] });
|
|
601
|
+
};
|
|
602
|
+
const ForwardProEditTable = forwardRef(ProEditTable);
|
|
603
|
+
var ProEditTable_default = ForwardProEditTable;
|
|
604
|
+
export {
|
|
605
|
+
ProEditTable_default as default
|
|
524
606
|
};
|
|
525
|
-
const ForwardProEditTable = /*#__PURE__*/forwardRef(ProEditTable);
|
|
526
|
-
|
|
527
|
-
// 导出组件
|
|
528
|
-
export default ForwardProEditTable;
|