@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,91 +1,65 @@
|
|
|
1
|
-
import
|
|
2
|
-
import scrollIntoView from
|
|
3
|
-
const toCssLength = value => typeof value ===
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 滚动到错误位置, 延迟200ms解决ProForm错误还未生成
|
|
7
|
-
*/
|
|
8
|
-
export const handleScrollError = (dom, root = document) => {
|
|
1
|
+
import pick from "lodash/pick";
|
|
2
|
+
import scrollIntoView from "scroll-into-view-if-needed";
|
|
3
|
+
const toCssLength = (value) => typeof value === "number" ? `${value}px` : value;
|
|
4
|
+
const handleScrollError = (dom, root = document) => {
|
|
9
5
|
setTimeout(() => {
|
|
10
6
|
const errorDom = dom || root.querySelector('[class*="form-item-has-error"]');
|
|
11
7
|
if (errorDom) {
|
|
12
8
|
scrollIntoView(errorDom, {
|
|
13
|
-
behavior:
|
|
14
|
-
block:
|
|
15
|
-
scrollMode:
|
|
9
|
+
behavior: "smooth",
|
|
10
|
+
block: "center",
|
|
11
|
+
scrollMode: "if-needed"
|
|
16
12
|
});
|
|
17
13
|
}
|
|
18
14
|
}, 200);
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @param id 目标元素的ID
|
|
24
|
-
* @param options 滚动选项
|
|
25
|
-
*/
|
|
26
|
-
export const handleScroll = (id, options) => {
|
|
27
|
-
const {
|
|
28
|
-
targetOffset,
|
|
29
|
-
scrollToError,
|
|
30
|
-
root = document,
|
|
31
|
-
target
|
|
32
|
-
} = options || {};
|
|
33
|
-
const dom = target || Array.from(root.querySelectorAll('.pro-step-item')).find(item => item.id === id);
|
|
16
|
+
const handleScroll = (id, options) => {
|
|
17
|
+
const { targetOffset, scrollToError, root = document, target } = options || {};
|
|
18
|
+
const dom = target || Array.from(root.querySelectorAll(".pro-step-item")).find((item) => item.id === id);
|
|
34
19
|
if (dom) {
|
|
35
|
-
// 查找指定id下的错误表单项
|
|
36
20
|
const errorDom = dom.querySelector('[class*="form-item-has-error"]');
|
|
37
21
|
if (errorDom && scrollToError) {
|
|
38
|
-
// 如果发现错误表单项,执行handleScrollError函数
|
|
39
22
|
handleScrollError(errorDom);
|
|
40
23
|
} else {
|
|
41
|
-
// 目录点击必须重新对齐到 sticky 区域下方,不能因“当前可见”而跳过。
|
|
42
24
|
const previousScrollMarginTop = dom.style.scrollMarginTop;
|
|
43
|
-
if (targetOffset !==
|
|
25
|
+
if (targetOffset !== void 0 && targetOffset !== null) {
|
|
44
26
|
dom.style.scrollMarginTop = toCssLength(targetOffset);
|
|
45
27
|
}
|
|
46
28
|
try {
|
|
47
29
|
scrollIntoView(dom, {
|
|
48
30
|
// compute-scroll-into-view 已计算 scroll-margin;custom behavior 避免外层库再次扣减。
|
|
49
|
-
behavior: actions => {
|
|
50
|
-
actions.forEach(({
|
|
51
|
-
el,
|
|
52
|
-
top,
|
|
53
|
-
left
|
|
54
|
-
}) => {
|
|
55
|
-
el.scroll({
|
|
56
|
-
top,
|
|
57
|
-
left,
|
|
58
|
-
behavior: 'smooth'
|
|
59
|
-
});
|
|
31
|
+
behavior: (actions) => {
|
|
32
|
+
actions.forEach(({ el, top, left }) => {
|
|
33
|
+
el.scroll({ top, left, behavior: "smooth" });
|
|
60
34
|
});
|
|
61
35
|
},
|
|
62
|
-
block:
|
|
63
|
-
scrollMode:
|
|
36
|
+
block: "start",
|
|
37
|
+
scrollMode: "always"
|
|
64
38
|
});
|
|
65
39
|
} finally {
|
|
66
|
-
if (targetOffset !==
|
|
40
|
+
if (targetOffset !== void 0 && targetOffset !== null) {
|
|
67
41
|
dom.style.scrollMarginTop = previousScrollMarginTop;
|
|
68
42
|
}
|
|
69
43
|
}
|
|
70
44
|
}
|
|
71
45
|
}
|
|
72
46
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* 获取加载模块数据信息
|
|
76
|
-
* @param registerMap 注册映射对象
|
|
77
|
-
* @returns 模块加载状态列表
|
|
78
|
-
*/
|
|
79
|
-
export const getLoadedMap = registerMap => {
|
|
80
|
-
if (!registerMap?.current) {
|
|
47
|
+
const getLoadedMap = (registerMap) => {
|
|
48
|
+
if (!(registerMap == null ? void 0 : registerMap.current)) {
|
|
81
49
|
return [];
|
|
82
50
|
}
|
|
83
|
-
const stepList = Object.values(registerMap
|
|
51
|
+
const stepList = Object.values(registerMap == null ? void 0 : registerMap.current).map((item) => {
|
|
84
52
|
return {
|
|
85
|
-
...
|
|
86
|
-
loaded: !document.querySelector(`.${item
|
|
53
|
+
...pick(item, ["id", "order", "title"]),
|
|
54
|
+
loaded: !document.querySelector(`.${item == null ? void 0 : item.id}-placeholder`)
|
|
87
55
|
};
|
|
88
56
|
});
|
|
89
57
|
return stepList;
|
|
90
58
|
};
|
|
91
|
-
|
|
59
|
+
var utils_default = handleScroll;
|
|
60
|
+
export {
|
|
61
|
+
utils_default as default,
|
|
62
|
+
getLoadedMap,
|
|
63
|
+
handleScroll,
|
|
64
|
+
handleScrollError
|
|
65
|
+
};
|
package/es/ProStepTab/index.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
const StepTabInstanceContext = /*#__PURE__*/createContext(null);
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 使用原生 JS 获取 URL 搜索参数
|
|
8
|
-
* @returns 当前 URL 的搜索参数和路径
|
|
9
|
-
*/
|
|
1
|
+
import React, { useState, useCallback, useEffect, createContext, useContext } from "react";
|
|
2
|
+
import isNaN from "lodash/isNaN";
|
|
3
|
+
const StepTabInstanceContext = createContext(null);
|
|
10
4
|
const useNativeLocation = () => {
|
|
11
5
|
const [location, setLocation] = useState({
|
|
12
6
|
search: window.location.search,
|
|
13
7
|
pathname: window.location.pathname
|
|
14
8
|
});
|
|
15
|
-
|
|
16
|
-
// 监听 popstate 事件,更新 location 状态
|
|
17
9
|
useEffect(() => {
|
|
18
10
|
const handleLocationChange = () => {
|
|
19
11
|
setLocation({
|
|
@@ -21,24 +13,17 @@ const useNativeLocation = () => {
|
|
|
21
13
|
pathname: window.location.pathname
|
|
22
14
|
});
|
|
23
15
|
};
|
|
24
|
-
window.addEventListener(
|
|
16
|
+
window.addEventListener("popstate", handleLocationChange);
|
|
25
17
|
return () => {
|
|
26
|
-
window.removeEventListener(
|
|
18
|
+
window.removeEventListener("popstate", handleLocationChange);
|
|
27
19
|
};
|
|
28
20
|
}, []);
|
|
29
21
|
return location;
|
|
30
22
|
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 步骤化Tab管理钩子,用于管理多步骤表单或流程的切换和验证
|
|
34
|
-
*
|
|
35
|
-
* @param {ProStepTabType} props 配置参数
|
|
36
|
-
* @returns {ProStepTabResultType} 返回步骤Tab相关方法和状态
|
|
37
|
-
*/
|
|
38
|
-
export function useStepTab(props = {}) {
|
|
23
|
+
function useStepTab(props = {}) {
|
|
39
24
|
const {
|
|
40
25
|
routerKeep = false,
|
|
41
|
-
routerSearchKey =
|
|
26
|
+
routerSearchKey = "tab",
|
|
42
27
|
validate = true,
|
|
43
28
|
onBeforeChange,
|
|
44
29
|
onAfterChange,
|
|
@@ -47,12 +32,8 @@ export function useStepTab(props = {}) {
|
|
|
47
32
|
queueSteps,
|
|
48
33
|
autoNext = false
|
|
49
34
|
} = props;
|
|
50
|
-
|
|
51
|
-
// 内部状态,避免全局污染
|
|
52
35
|
const [handlesState, setHandlesState] = useState({});
|
|
53
36
|
const location = useNativeLocation();
|
|
54
|
-
|
|
55
|
-
// 获取初始激活的tab key
|
|
56
37
|
const getInitialActiveKey = useCallback(() => {
|
|
57
38
|
if (routerKeep) {
|
|
58
39
|
const urlSearchParams = new URLSearchParams(location.search);
|
|
@@ -61,40 +42,30 @@ export function useStepTab(props = {}) {
|
|
|
61
42
|
return tabValue;
|
|
62
43
|
}
|
|
63
44
|
}
|
|
64
|
-
return defaultActiveKey ||
|
|
45
|
+
return defaultActiveKey || "1";
|
|
65
46
|
}, [routerKeep, routerSearchKey, location.search, defaultActiveKey]);
|
|
66
|
-
|
|
67
|
-
// 获取初始激活的步骤
|
|
68
47
|
const getInitialStep = useCallback(() => {
|
|
69
48
|
if (routerKeep) {
|
|
70
49
|
const urlSearchParams = new URLSearchParams(location.search);
|
|
71
50
|
const stepValue = urlSearchParams.get(routerSearchKey);
|
|
72
|
-
|
|
73
|
-
if (stepValue && !_isNaN(Number(stepValue))) {
|
|
51
|
+
if (stepValue && !isNaN(Number(stepValue))) {
|
|
74
52
|
return Number(stepValue);
|
|
75
53
|
}
|
|
76
54
|
}
|
|
77
55
|
return defaultStep;
|
|
78
56
|
}, [routerKeep, routerSearchKey, location.search, defaultStep]);
|
|
79
57
|
const [activeKey, setActiveKeyState] = useState(getInitialActiveKey());
|
|
80
|
-
const [step, setStepState] = useState(getInitialStep());
|
|
58
|
+
const [step, setStepState] = useState(getInitialStep());
|
|
81
59
|
const [loading, setLoading] = useState(false);
|
|
82
|
-
|
|
83
|
-
// 同步URL参数
|
|
84
60
|
useEffect(() => {
|
|
85
61
|
if (routerKeep && activeKey) {
|
|
86
|
-
// 更新URL参数
|
|
87
62
|
const urlSearchParams = new URLSearchParams(location.search);
|
|
88
63
|
urlSearchParams.set(routerSearchKey, activeKey);
|
|
89
|
-
|
|
90
|
-
// 使用原生 history API 更新 URL
|
|
91
64
|
const newUrl = `${location.pathname}?${urlSearchParams.toString()}`;
|
|
92
|
-
window.history.replaceState(null,
|
|
65
|
+
window.history.replaceState(null, "", newUrl);
|
|
93
66
|
}
|
|
94
67
|
}, [activeKey, routerKeep, routerSearchKey, location]);
|
|
95
|
-
|
|
96
|
-
// 创建一个包装函数,自动处理loading状态
|
|
97
|
-
const wrapHandleWithLoading = useCallback(fn => {
|
|
68
|
+
const wrapHandleWithLoading = useCallback((fn) => {
|
|
98
69
|
return async () => {
|
|
99
70
|
setLoading(true);
|
|
100
71
|
try {
|
|
@@ -107,82 +78,72 @@ export function useStepTab(props = {}) {
|
|
|
107
78
|
}
|
|
108
79
|
};
|
|
109
80
|
}, []);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
81
|
+
const registerHandle = useCallback(
|
|
82
|
+
(key, handler) => {
|
|
83
|
+
setHandlesState((prev) => ({
|
|
84
|
+
...prev,
|
|
85
|
+
[key]: wrapHandleWithLoading(handler)
|
|
86
|
+
}));
|
|
87
|
+
},
|
|
88
|
+
[wrapHandleWithLoading]
|
|
89
|
+
);
|
|
90
|
+
const getHandle = useCallback(
|
|
91
|
+
(key) => {
|
|
92
|
+
return handlesState[key];
|
|
93
|
+
},
|
|
94
|
+
[handlesState]
|
|
95
|
+
);
|
|
96
|
+
const validateAndChange = useCallback(
|
|
97
|
+
async (targetKey) => {
|
|
98
|
+
if (targetKey === activeKey)
|
|
99
|
+
return true;
|
|
100
|
+
try {
|
|
101
|
+
const currentHandler = handlesState[activeKey];
|
|
102
|
+
if (currentHandler && validate) {
|
|
103
|
+
const handleResult = await currentHandler();
|
|
104
|
+
if (!handleResult) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
135
107
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
108
|
+
if (onBeforeChange) {
|
|
109
|
+
const beforeResult = await onBeforeChange(activeKey, targetKey);
|
|
110
|
+
if (beforeResult === false) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
setActiveKeyState(targetKey);
|
|
115
|
+
if (onAfterChange) {
|
|
116
|
+
onAfterChange(targetKey);
|
|
143
117
|
}
|
|
118
|
+
return true;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("Tab切换验证失败:", error);
|
|
121
|
+
return false;
|
|
144
122
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
123
|
+
},
|
|
124
|
+
[activeKey, validate, onBeforeChange, onAfterChange, handlesState]
|
|
125
|
+
);
|
|
126
|
+
const setCheckActiveKey = useCallback(
|
|
127
|
+
async (targetKey, validate2) => {
|
|
128
|
+
if (validate2 === false) {
|
|
129
|
+
setActiveKeyState(targetKey);
|
|
130
|
+
return true;
|
|
152
131
|
}
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
}, [activeKey, validate, onBeforeChange, onAfterChange, handlesState]);
|
|
160
|
-
|
|
161
|
-
// 设置激活的key
|
|
162
|
-
const setCheckActiveKey = useCallback(async (targetKey, validate) => {
|
|
163
|
-
if (validate === false) {
|
|
164
|
-
setActiveKeyState(targetKey);
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
// 执行表单验证和切换
|
|
168
|
-
return validateAndChange(targetKey);
|
|
169
|
-
}, [validateAndChange]);
|
|
170
|
-
|
|
171
|
-
// 执行当前步骤处理函数
|
|
132
|
+
return validateAndChange(targetKey);
|
|
133
|
+
},
|
|
134
|
+
[validateAndChange]
|
|
135
|
+
);
|
|
172
136
|
const saveHandle = useCallback(async () => {
|
|
173
137
|
const handler = handlesState[activeKey];
|
|
174
138
|
if (handler) {
|
|
175
139
|
const result = await handler();
|
|
176
|
-
// 添加autoNext功能
|
|
177
140
|
if (result && autoNext) {
|
|
178
|
-
// 只有当activeKey能转换为数字时才执行自动跳转
|
|
179
141
|
const currentKeyNum = Number(activeKey);
|
|
180
|
-
if (!
|
|
142
|
+
if (!isNaN(currentKeyNum)) {
|
|
181
143
|
let nextKey = String(currentKeyNum + 1);
|
|
182
144
|
if (Number(nextKey) > queueSteps) {
|
|
183
145
|
nextKey = String(queueSteps);
|
|
184
146
|
}
|
|
185
|
-
// 自动跳转到下一个tab
|
|
186
147
|
await setCheckActiveKey(nextKey, false);
|
|
187
148
|
}
|
|
188
149
|
}
|
|
@@ -193,16 +154,15 @@ export function useStepTab(props = {}) {
|
|
|
193
154
|
}
|
|
194
155
|
return Promise.resolve(true);
|
|
195
156
|
}, [activeKey, handlesState, autoNext, queueSteps, setCheckActiveKey]);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// 重置handles,用于清空或组件卸载时调用
|
|
157
|
+
const setStep = useCallback(
|
|
158
|
+
(step2) => {
|
|
159
|
+
if (step2 > queueSteps) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
setStepState(step2);
|
|
163
|
+
},
|
|
164
|
+
[queueSteps]
|
|
165
|
+
);
|
|
206
166
|
const resetHandles = useCallback(() => {
|
|
207
167
|
setHandlesState({});
|
|
208
168
|
}, []);
|
|
@@ -221,36 +181,21 @@ export function useStepTab(props = {}) {
|
|
|
221
181
|
};
|
|
222
182
|
return stepTabInstance;
|
|
223
183
|
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 在子组件中获取父级 StepTab 实例的钩子
|
|
227
|
-
* @returns {ProStepTabResultType} 步骤Tab实例
|
|
228
|
-
*/
|
|
229
|
-
export function useStepTabInstance() {
|
|
184
|
+
function useStepTabInstance() {
|
|
230
185
|
const context = useContext(StepTabInstanceContext);
|
|
231
186
|
if (context === null) {
|
|
232
|
-
throw new Error(
|
|
187
|
+
throw new Error("useStepTabInstance must be used inside a ProStepTab component");
|
|
233
188
|
}
|
|
234
189
|
return context;
|
|
235
190
|
}
|
|
236
|
-
|
|
237
|
-
// 扩展FC类型,添加静态方法
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* ProStepTab 组件
|
|
241
|
-
*/
|
|
242
|
-
const ProStepTab = ({
|
|
243
|
-
children,
|
|
244
|
-
...rest
|
|
245
|
-
}) => {
|
|
191
|
+
const ProStepTab = ({ children, ...rest }) => {
|
|
246
192
|
const stepTabInstance = useStepTab(rest);
|
|
247
|
-
return
|
|
248
|
-
value: stepTabInstance
|
|
249
|
-
}, children);
|
|
193
|
+
return React.createElement(StepTabInstanceContext.Provider, { value: stepTabInstance }, children);
|
|
250
194
|
};
|
|
251
|
-
|
|
252
|
-
// 将 useStepTabInstance 挂载到 ProStepTab 上作为静态方法
|
|
253
195
|
ProStepTab.useStepTabInstance = useStepTabInstance;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
196
|
+
var ProStepTab_default = ProStepTab;
|
|
197
|
+
export {
|
|
198
|
+
ProStepTab_default as default,
|
|
199
|
+
useStepTab,
|
|
200
|
+
useStepTabInstance
|
|
201
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
onClick
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onClick: onClick,
|
|
12
|
-
children: /*#__PURE__*/_jsx(EditOutlined, {})
|
|
13
|
-
});
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { EditOutlined } from "@ant-design/icons";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
const EditIcon = ({ onClick }) => {
|
|
5
|
+
const cls = classNames("pro-table-editable-cell-edit-icon");
|
|
6
|
+
return /* @__PURE__ */ jsx("span", { className: cls, onClick, children: /* @__PURE__ */ jsx(EditOutlined, {}) });
|
|
7
|
+
};
|
|
8
|
+
var EditIcon_default = EditIcon;
|
|
9
|
+
export {
|
|
10
|
+
EditIcon_default as default
|
|
14
11
|
};
|
|
15
|
-
export default EditIcon;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Form } from
|
|
4
|
-
import classNames from
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
import { Form } from "antd";
|
|
4
|
+
import classNames from "classnames";
|
|
5
|
+
import isEqual from "lodash/isEqual";
|
|
5
6
|
import * as componentMap from "../../../ProForm/components";
|
|
6
7
|
import EditIcon from "./EditIcon";
|
|
7
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
8
|
const InternalCell = ({
|
|
9
9
|
value,
|
|
10
10
|
record,
|
|
@@ -17,19 +17,10 @@ const InternalCell = ({
|
|
|
17
17
|
}) => {
|
|
18
18
|
const [editing, setEditing] = useState(false);
|
|
19
19
|
const snapshotRef = useRef(value);
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
fieldProps = {},
|
|
23
|
-
rules,
|
|
24
|
-
required,
|
|
25
|
-
valueType
|
|
26
|
-
} = editConfig;
|
|
27
|
-
const {
|
|
28
|
-
onBlur: onBlurCallback,
|
|
29
|
-
...restFieldProps
|
|
30
|
-
} = fieldProps;
|
|
20
|
+
const { type = "Input", fieldProps = {}, rules, required, valueType } = editConfig;
|
|
21
|
+
const { onBlur: onBlurCallback, ...restFieldProps } = fieldProps;
|
|
31
22
|
const Component = componentMap[type] ?? componentMap.Input;
|
|
32
|
-
const wrapperClassName = classNames(
|
|
23
|
+
const wrapperClassName = classNames("pro-table-editable-cell-wrapper");
|
|
33
24
|
const handleEditIconClick = () => {
|
|
34
25
|
snapshotRef.current = value;
|
|
35
26
|
form.setFieldValue(fieldName, value);
|
|
@@ -39,7 +30,7 @@ const InternalCell = ({
|
|
|
39
30
|
try {
|
|
40
31
|
await form.validateFields([fieldName]);
|
|
41
32
|
const newValue = form.getFieldValue(fieldName);
|
|
42
|
-
if (
|
|
33
|
+
if (isEqual(newValue, snapshotRef.current)) {
|
|
43
34
|
setEditing(false);
|
|
44
35
|
return;
|
|
45
36
|
}
|
|
@@ -53,69 +44,44 @@ const InternalCell = ({
|
|
|
53
44
|
}
|
|
54
45
|
setEditing(false);
|
|
55
46
|
} catch {
|
|
56
|
-
// Validation failed - stay in edit mode
|
|
57
47
|
}
|
|
58
48
|
};
|
|
59
49
|
if (!editing) {
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}), /*#__PURE__*/_jsx(EditIcon, {
|
|
65
|
-
onClick: handleEditIconClick
|
|
66
|
-
})]
|
|
67
|
-
});
|
|
50
|
+
return /* @__PURE__ */ jsxs("span", { className: wrapperClassName, children: [
|
|
51
|
+
/* @__PURE__ */ jsx("span", { children: displayContent ?? "-" }),
|
|
52
|
+
/* @__PURE__ */ jsx(EditIcon, { onClick: handleEditIconClick })
|
|
53
|
+
] });
|
|
68
54
|
}
|
|
69
|
-
const formItem =
|
|
70
|
-
name: fieldName,
|
|
71
|
-
rules: rules,
|
|
72
|
-
required: required,
|
|
73
|
-
noStyle: true,
|
|
74
|
-
children: /*#__PURE__*/_jsx(Component, {
|
|
75
|
-
...restFieldProps,
|
|
76
|
-
valueType: valueType,
|
|
77
|
-
autoFocus: true,
|
|
78
|
-
onBlur: handleBlur
|
|
79
|
-
})
|
|
80
|
-
});
|
|
55
|
+
const formItem = /* @__PURE__ */ jsx(Form.Item, { name: fieldName, rules, required, noStyle: true, children: /* @__PURE__ */ jsx(Component, { ...restFieldProps, valueType, autoFocus: true, onBlur: handleBlur }) });
|
|
81
56
|
if (!wrapInForm) {
|
|
82
57
|
return formItem;
|
|
83
58
|
}
|
|
84
|
-
return
|
|
85
|
-
form: form,
|
|
86
|
-
component: false,
|
|
87
|
-
children: formItem
|
|
88
|
-
});
|
|
59
|
+
return /* @__PURE__ */ jsx(Form, { form, component: false, children: formItem });
|
|
89
60
|
};
|
|
90
|
-
const PerCellEditableCell = props => {
|
|
61
|
+
const PerCellEditableCell = (props) => {
|
|
91
62
|
const [form] = Form.useForm();
|
|
92
|
-
const fieldName = Array.isArray(props.dataIndex) ? props.dataIndex.join(
|
|
93
|
-
return
|
|
94
|
-
...props,
|
|
95
|
-
form: form,
|
|
96
|
-
fieldName: fieldName,
|
|
97
|
-
wrapInForm: true
|
|
98
|
-
});
|
|
63
|
+
const fieldName = Array.isArray(props.dataIndex) ? props.dataIndex.join("_") : props.dataIndex;
|
|
64
|
+
return /* @__PURE__ */ jsx(InternalCell, { ...props, form, fieldName, wrapInForm: true });
|
|
99
65
|
};
|
|
100
|
-
const SharedFormEditableCell = props => {
|
|
101
|
-
const fieldName = props.sharedFieldName ?? (Array.isArray(props.dataIndex) ? props.dataIndex.join(
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
66
|
+
const SharedFormEditableCell = (props) => {
|
|
67
|
+
const fieldName = props.sharedFieldName ?? (Array.isArray(props.dataIndex) ? props.dataIndex.join("_") : props.dataIndex);
|
|
68
|
+
return /* @__PURE__ */ jsx(
|
|
69
|
+
InternalCell,
|
|
70
|
+
{
|
|
71
|
+
...props,
|
|
72
|
+
form: props.sharedForm,
|
|
73
|
+
fieldName,
|
|
74
|
+
wrapInForm: false
|
|
75
|
+
}
|
|
76
|
+
);
|
|
108
77
|
};
|
|
109
|
-
const EditableCell = props => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (props.editMode === 'shared-form' && props.sharedForm) {
|
|
113
|
-
return /*#__PURE__*/_jsx(SharedFormEditableCell, {
|
|
114
|
-
...props
|
|
115
|
-
});
|
|
78
|
+
const EditableCell = (props) => {
|
|
79
|
+
if (props.editMode === "shared-form" && props.sharedForm) {
|
|
80
|
+
return /* @__PURE__ */ jsx(SharedFormEditableCell, { ...props });
|
|
116
81
|
}
|
|
117
|
-
return
|
|
118
|
-
|
|
119
|
-
|
|
82
|
+
return /* @__PURE__ */ jsx(PerCellEditableCell, { ...props });
|
|
83
|
+
};
|
|
84
|
+
var EditableCell_default = EditableCell;
|
|
85
|
+
export {
|
|
86
|
+
EditableCell_default as default
|
|
120
87
|
};
|
|
121
|
-
export default EditableCell;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|