@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,32 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { validate } from '@zat-design/utils';
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from "antd";
|
|
3
|
+
import isFunction from "lodash/isFunction";
|
|
4
|
+
import isString from "lodash/isString";
|
|
5
|
+
import omit from "lodash/omit";
|
|
6
|
+
import { validate } from "@zat-design/utils";
|
|
8
7
|
import valueTypeMap from "../../../../utils/valueType";
|
|
9
8
|
import locale from "../../../../../locale";
|
|
10
9
|
import { isSelect } from "../../../../utils";
|
|
11
10
|
import { rulesCreator } from "../../../../utils/rulesCreator";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* 插入间隔符
|
|
15
|
-
* @param columns 表单配置数组
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export const insertSeparator = (columns, space) => {
|
|
19
|
-
if (!space?.separator) {
|
|
11
|
+
const insertSeparator = (columns, space) => {
|
|
12
|
+
if (!(space == null ? void 0 : space.separator)) {
|
|
20
13
|
return columns;
|
|
21
14
|
}
|
|
22
15
|
const separatorIndexs = (() => {
|
|
23
16
|
let reuslt = [];
|
|
24
|
-
if (validate.isEmpty(space
|
|
17
|
+
if (validate.isEmpty(space == null ? void 0 : space.separatorIndex)) {
|
|
25
18
|
return reuslt;
|
|
26
19
|
}
|
|
27
|
-
|
|
28
|
-
// 如果 index 是数字,将其转换为数组
|
|
29
|
-
if (typeof space?.separatorIndex === 'number') {
|
|
20
|
+
if (typeof (space == null ? void 0 : space.separatorIndex) === "number") {
|
|
30
21
|
reuslt.push(space.separatorIndex);
|
|
31
22
|
}
|
|
32
23
|
if (Array.isArray(space.separatorIndex)) {
|
|
@@ -35,17 +26,13 @@ export const insertSeparator = (columns, space) => {
|
|
|
35
26
|
return reuslt;
|
|
36
27
|
})();
|
|
37
28
|
return columns.reduce((result, current, index, array) => {
|
|
38
|
-
// 将当前元素添加到结果数组中
|
|
39
29
|
result.push(current);
|
|
40
|
-
if (separatorIndexs
|
|
41
|
-
separatorIndexs.forEach(separatorIndex => {
|
|
30
|
+
if (separatorIndexs == null ? void 0 : separatorIndexs.length) {
|
|
31
|
+
separatorIndexs.forEach((separatorIndex) => {
|
|
42
32
|
if (index === separatorIndex) {
|
|
43
33
|
result.push({
|
|
44
34
|
separator: true,
|
|
45
|
-
component:
|
|
46
|
-
className: "group-separator",
|
|
47
|
-
children: space.separator
|
|
48
|
-
}),
|
|
35
|
+
component: /* @__PURE__ */ jsx(Button, { className: "group-separator", children: space.separator }),
|
|
49
36
|
fieldProps: {
|
|
50
37
|
disabled: true
|
|
51
38
|
}
|
|
@@ -53,14 +40,10 @@ export const insertSeparator = (columns, space) => {
|
|
|
53
40
|
}
|
|
54
41
|
});
|
|
55
42
|
} else {
|
|
56
|
-
// 如果当前元素不是最后一个元素,则添加间隔符
|
|
57
43
|
if (index < array.length - 1) {
|
|
58
44
|
result.push({
|
|
59
45
|
separator: true,
|
|
60
|
-
component:
|
|
61
|
-
className: "group-separator",
|
|
62
|
-
children: space.separator
|
|
63
|
-
}),
|
|
46
|
+
component: /* @__PURE__ */ jsx(Button, { className: "group-separator", children: space.separator }),
|
|
64
47
|
fieldProps: {
|
|
65
48
|
disabled: true
|
|
66
49
|
}
|
|
@@ -70,87 +53,47 @@ export const insertSeparator = (columns, space) => {
|
|
|
70
53
|
return result;
|
|
71
54
|
}, []);
|
|
72
55
|
};
|
|
73
|
-
|
|
74
|
-
/** 带出event的组件默认取值方法 */
|
|
75
|
-
export function defaultGetValueFromEvent(valuePropName, ...args) {
|
|
56
|
+
function defaultGetValueFromEvent(valuePropName, ...args) {
|
|
76
57
|
const event = args[0];
|
|
77
|
-
if (event && event.target && typeof event.target ===
|
|
58
|
+
if (event && event.target && typeof event.target === "object" && valuePropName in event.target) {
|
|
78
59
|
return event.target[valuePropName];
|
|
79
60
|
}
|
|
80
61
|
return event;
|
|
81
62
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
export const transformNamesString = arr => {
|
|
85
|
-
const result = arr.map(subArr => {
|
|
63
|
+
const transformNamesString = (arr) => {
|
|
64
|
+
const result = arr.map((subArr) => {
|
|
86
65
|
if (Array.isArray(subArr)) {
|
|
87
|
-
return subArr.join(
|
|
66
|
+
return subArr.join("_");
|
|
88
67
|
}
|
|
89
68
|
return subArr;
|
|
90
69
|
});
|
|
91
70
|
return result;
|
|
92
71
|
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Input TextArea 小写自动转大写
|
|
96
|
-
* @param type 组件类型
|
|
97
|
-
* @param upperCase 是否小写转大写
|
|
98
|
-
* @returns {}
|
|
99
|
-
*/
|
|
100
|
-
export const isUpperCase = (type, upperCase) => {
|
|
72
|
+
const isUpperCase = (type, upperCase) => {
|
|
101
73
|
const result = {};
|
|
102
|
-
if ([
|
|
103
|
-
result.getValueFromEvent = event => {
|
|
74
|
+
if (["Input", "TextArea"].includes(type) && upperCase) {
|
|
75
|
+
result.getValueFromEvent = (event) => {
|
|
76
|
+
var _a, _b;
|
|
104
77
|
if (Array.isArray(event)) {
|
|
105
|
-
return event.map(value => {
|
|
106
|
-
const
|
|
107
|
-
return
|
|
78
|
+
return event.map((value) => {
|
|
79
|
+
const newValue2 = value == null ? void 0 : value.replace(/[^a-zA-Z]/g, "");
|
|
80
|
+
return (newValue2 == null ? void 0 : newValue2.toUpperCase()) || "";
|
|
108
81
|
});
|
|
109
82
|
}
|
|
110
|
-
const newValue = event.target
|
|
111
|
-
return newValue.toUpperCase() ||
|
|
83
|
+
const newValue = (_b = (_a = event.target) == null ? void 0 : _a.value) == null ? void 0 : _b.replace(/[^a-zA-Z]/g, "");
|
|
84
|
+
return newValue.toUpperCase() || "";
|
|
112
85
|
};
|
|
113
86
|
}
|
|
114
87
|
return result;
|
|
115
88
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const {
|
|
119
|
-
form,
|
|
120
|
-
index,
|
|
121
|
-
namePath,
|
|
122
|
-
disabled,
|
|
123
|
-
show,
|
|
124
|
-
component,
|
|
125
|
-
fieldProps,
|
|
126
|
-
desensitization
|
|
127
|
-
} = params;
|
|
89
|
+
const getReactiveProps = (params) => {
|
|
90
|
+
const { form, index, namePath, disabled, show, component, fieldProps, desensitization } = params;
|
|
128
91
|
const values = namePath ? form.getFieldValue(namePath) : form.getFieldsValue();
|
|
129
|
-
const _disabled =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}) :
|
|
134
|
-
const _show = _isFunction(show) ? show(values, {
|
|
135
|
-
form,
|
|
136
|
-
index,
|
|
137
|
-
namePath
|
|
138
|
-
}) : show;
|
|
139
|
-
const _component = _isFunction(component) ? component(values, {
|
|
140
|
-
form,
|
|
141
|
-
index,
|
|
142
|
-
namePath
|
|
143
|
-
}) : component;
|
|
144
|
-
const _fieldProps = _isFunction(fieldProps) ? fieldProps(values, {
|
|
145
|
-
form,
|
|
146
|
-
index,
|
|
147
|
-
namePath
|
|
148
|
-
}) : fieldProps;
|
|
149
|
-
const _desensitization = _isFunction(desensitization) ? desensitization(values, {
|
|
150
|
-
form,
|
|
151
|
-
index,
|
|
152
|
-
namePath
|
|
153
|
-
}) : desensitization;
|
|
92
|
+
const _disabled = isFunction(disabled) ? disabled(values, { form, index, namePath }) : disabled;
|
|
93
|
+
const _show = isFunction(show) ? show(values, { form, index, namePath }) : show;
|
|
94
|
+
const _component = isFunction(component) ? component(values, { form, index, namePath }) : component;
|
|
95
|
+
const _fieldProps = isFunction(fieldProps) ? fieldProps(values, { form, index, namePath }) : fieldProps;
|
|
96
|
+
const _desensitization = isFunction(desensitization) ? desensitization(values, { form, index, namePath }) : desensitization;
|
|
154
97
|
return {
|
|
155
98
|
disabled: _disabled,
|
|
156
99
|
show: _show,
|
|
@@ -159,37 +102,26 @@ export const getReactiveProps = params => {
|
|
|
159
102
|
desensitization: _desensitization
|
|
160
103
|
};
|
|
161
104
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const {
|
|
165
|
-
|
|
166
|
-
} = params;
|
|
167
|
-
const transform = valueTypeMap[valueType]?.(params);
|
|
105
|
+
const getValueTypeTrans = (params) => {
|
|
106
|
+
var _a, _b;
|
|
107
|
+
const { valueType } = params;
|
|
108
|
+
const transform = (_b = (_a = valueTypeMap)[valueType]) == null ? void 0 : _b.call(_a, params);
|
|
168
109
|
return transform;
|
|
169
110
|
};
|
|
170
|
-
const getTrim = value => {
|
|
171
|
-
return value
|
|
111
|
+
const getTrim = (value) => {
|
|
112
|
+
return (value == null ? void 0 : value.trim()) || "";
|
|
172
113
|
};
|
|
173
|
-
const getUpperCase = value => {
|
|
174
|
-
const _value = value
|
|
175
|
-
return _value.toUpperCase() ||
|
|
114
|
+
const getUpperCase = (value) => {
|
|
115
|
+
const _value = value == null ? void 0 : value.replace(/[^a-zA-Z]/g, "");
|
|
116
|
+
return _value.toUpperCase() || "";
|
|
176
117
|
};
|
|
177
|
-
|
|
178
|
-
/** 执行所有中间件 返回处理后的值 */
|
|
179
|
-
export const getValueMiddleware = (value, callbacks = []) => {
|
|
118
|
+
const getValueMiddleware = (value, callbacks = []) => {
|
|
180
119
|
return callbacks.reduce((preValue, cb) => {
|
|
181
|
-
return cb
|
|
120
|
+
return cb == null ? void 0 : cb(preValue);
|
|
182
121
|
}, value);
|
|
183
122
|
};
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
export const valueFromEventWrapper = (column, args) => {
|
|
187
|
-
const {
|
|
188
|
-
getValueFromEvent,
|
|
189
|
-
valuePropName = 'value',
|
|
190
|
-
trim,
|
|
191
|
-
upperCase
|
|
192
|
-
} = column;
|
|
123
|
+
const valueFromEventWrapper = (column, args) => {
|
|
124
|
+
const { getValueFromEvent, valuePropName = "value", trim, upperCase } = column;
|
|
193
125
|
let newValue;
|
|
194
126
|
if (getValueFromEvent) {
|
|
195
127
|
newValue = getValueFromEvent(...args);
|
|
@@ -197,19 +129,13 @@ export const valueFromEventWrapper = (column, args) => {
|
|
|
197
129
|
newValue = defaultGetValueFromEvent(valuePropName, ...args);
|
|
198
130
|
}
|
|
199
131
|
const list = [];
|
|
200
|
-
if (trim)
|
|
201
|
-
|
|
132
|
+
if (trim)
|
|
133
|
+
list.push(getTrim);
|
|
134
|
+
if (upperCase)
|
|
135
|
+
list.push(getUpperCase);
|
|
202
136
|
return getValueMiddleware(newValue, list);
|
|
203
137
|
};
|
|
204
|
-
|
|
205
|
-
// ==================== 原 formItemHelpers.ts 内容 ====================
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* 创建FormItem属性(Hook版本)
|
|
209
|
-
*/
|
|
210
|
-
export const useFormItemProps = (column, contextProps, groupProps) => {
|
|
211
|
-
// Debug info removed for production
|
|
212
|
-
|
|
138
|
+
const useFormItemProps = (column, contextProps, groupProps) => {
|
|
213
139
|
const {
|
|
214
140
|
name,
|
|
215
141
|
label,
|
|
@@ -224,54 +150,35 @@ export const useFormItemProps = (column, contextProps, groupProps) => {
|
|
|
224
150
|
fieldProps = {},
|
|
225
151
|
...otherFormItemProps
|
|
226
152
|
} = column;
|
|
227
|
-
const {
|
|
228
|
-
form,
|
|
229
|
-
namePath
|
|
230
|
-
} = contextProps;
|
|
231
|
-
|
|
232
|
-
// 构建完整的name路径
|
|
153
|
+
const { form, namePath } = contextProps;
|
|
233
154
|
const fullName = namePath ? [...namePath, name] : name;
|
|
234
|
-
|
|
235
|
-
// 处理依赖关系 - 支持相对路径和绝对路径
|
|
236
155
|
const safeDependencies = Array.isArray(dependencies) ? dependencies : [];
|
|
237
|
-
const processedDependencies = safeDependencies.map(dep => {
|
|
238
|
-
if (typeof dep ===
|
|
239
|
-
// 相对路径:同Group内的其他字段
|
|
156
|
+
const processedDependencies = safeDependencies.map((dep) => {
|
|
157
|
+
if (typeof dep === "string") {
|
|
240
158
|
return namePath ? [...namePath, dep] : dep;
|
|
241
159
|
}
|
|
242
|
-
return dep;
|
|
160
|
+
return dep;
|
|
243
161
|
});
|
|
244
|
-
|
|
245
|
-
// 处理校验规则 - 确保rules是数组
|
|
246
162
|
const safeRules = Array.isArray(rules) ? rules : [];
|
|
247
|
-
|
|
248
|
-
// 先调用 rulesCreator 转换自定义校验类型(如 type: 'isEmail')
|
|
249
163
|
const transformedRules = rulesCreator({
|
|
250
164
|
rules: safeRules,
|
|
251
|
-
label
|
|
252
|
-
isSelect: isSelect({
|
|
253
|
-
|
|
254
|
-
type
|
|
255
|
-
}),
|
|
256
|
-
names: undefined,
|
|
165
|
+
label,
|
|
166
|
+
isSelect: isSelect({ dataSource: fieldProps == null ? void 0 : fieldProps.dataSource, type }),
|
|
167
|
+
names: void 0,
|
|
257
168
|
// 灵活模式不使用 names
|
|
258
169
|
required
|
|
259
170
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
const processedRules = transformedRules.map(rule => {
|
|
263
|
-
if (typeof rule.validator === 'function') {
|
|
171
|
+
const processedRules = transformedRules.map((rule) => {
|
|
172
|
+
if (typeof rule.validator === "function") {
|
|
264
173
|
const originalValidator = rule.validator;
|
|
265
174
|
return {
|
|
266
175
|
...rule,
|
|
267
176
|
validator: async (ruleObj, value) => {
|
|
268
|
-
// 为validator提供form和当前字段上下文
|
|
269
177
|
const enhancedRule = {
|
|
270
178
|
...ruleObj,
|
|
271
179
|
form,
|
|
272
180
|
field: fullName,
|
|
273
|
-
getFieldValue: fieldName => {
|
|
274
|
-
// 支持相对路径获取同Group内字段值
|
|
181
|
+
getFieldValue: (fieldName) => {
|
|
275
182
|
const targetName = namePath ? [...namePath, fieldName] : fieldName;
|
|
276
183
|
return form.getFieldValue(targetName);
|
|
277
184
|
}
|
|
@@ -282,15 +189,11 @@ export const useFormItemProps = (column, contextProps, groupProps) => {
|
|
|
282
189
|
}
|
|
283
190
|
return rule;
|
|
284
191
|
});
|
|
285
|
-
|
|
286
|
-
// 处理disabled状态
|
|
287
|
-
const lastDisabled = groupProps.formDisabled ?? columnDisabled ?? fieldProps?.disabled ?? groupProps.disabled;
|
|
288
|
-
|
|
289
|
-
// 直接处理校验规则,避免在非Hook函数中使用useRules
|
|
192
|
+
const lastDisabled = groupProps.formDisabled ?? columnDisabled ?? (fieldProps == null ? void 0 : fieldProps.disabled) ?? groupProps.disabled;
|
|
290
193
|
const internalRule = {
|
|
291
194
|
rules: processedRules,
|
|
292
195
|
required,
|
|
293
|
-
label
|
|
196
|
+
label
|
|
294
197
|
};
|
|
295
198
|
return {
|
|
296
199
|
name: fullName,
|
|
@@ -304,40 +207,16 @@ export const useFormItemProps = (column, contextProps, groupProps) => {
|
|
|
304
207
|
...internalRule
|
|
305
208
|
};
|
|
306
209
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const {
|
|
313
|
-
type,
|
|
314
|
-
fieldProps = {},
|
|
315
|
-
valueType,
|
|
316
|
-
switchValue,
|
|
317
|
-
toISOString,
|
|
318
|
-
toCSTString
|
|
319
|
-
} = column;
|
|
320
|
-
|
|
321
|
-
// 处理placeholder
|
|
322
|
-
const {
|
|
323
|
-
label,
|
|
324
|
-
placeholder,
|
|
325
|
-
dataSource
|
|
326
|
-
} = fieldProps;
|
|
327
|
-
const {
|
|
328
|
-
label: formLabel
|
|
329
|
-
} = formItemProps;
|
|
330
|
-
const _isSelect = isSelect({
|
|
331
|
-
dataSource,
|
|
332
|
-
type
|
|
333
|
-
});
|
|
210
|
+
const createComponentProps = (column, formItemProps) => {
|
|
211
|
+
const { type, fieldProps = {}, valueType, switchValue, toISOString, toCSTString } = column;
|
|
212
|
+
const { label, placeholder, dataSource } = fieldProps;
|
|
213
|
+
const { label: formLabel } = formItemProps;
|
|
214
|
+
const _isSelect = isSelect({ dataSource, type });
|
|
334
215
|
const placeholderHandle = () => {
|
|
335
|
-
const _label =
|
|
336
|
-
const _formLabel =
|
|
337
|
-
return placeholder || `${_isSelect ? `${locale.ProForm.selectPlaceHolder}` : `${locale.ProForm.inputPlaceholder}`}${_label || _formLabel ||
|
|
216
|
+
const _label = isString(label) ? label : "";
|
|
217
|
+
const _formLabel = isString(formLabel) ? formLabel : "";
|
|
218
|
+
return placeholder || `${_isSelect ? `${locale.ProForm.selectPlaceHolder}` : `${locale.ProForm.inputPlaceholder}`}${_label || _formLabel || ""}`;
|
|
338
219
|
};
|
|
339
|
-
|
|
340
|
-
// 值类型转换
|
|
341
220
|
const transform = getValueTypeTrans({
|
|
342
221
|
type,
|
|
343
222
|
valueType,
|
|
@@ -346,75 +225,81 @@ export const createComponentProps = (column, formItemProps) => {
|
|
|
346
225
|
toCSTString,
|
|
347
226
|
mode: fieldProps.mode
|
|
348
227
|
});
|
|
349
|
-
|
|
350
|
-
// 组件基本属性
|
|
351
228
|
const componentProps = {
|
|
352
229
|
placeholder: placeholderHandle(),
|
|
353
230
|
...fieldProps,
|
|
354
231
|
disabled: formItemProps.disabled
|
|
355
232
|
};
|
|
356
|
-
|
|
357
|
-
// 时间范围placeholder特殊处理
|
|
358
|
-
if (type === 'RangePicker' && !fieldProps?.placeholder) {
|
|
233
|
+
if (type === "RangePicker" && !(fieldProps == null ? void 0 : fieldProps.placeholder)) {
|
|
359
234
|
delete componentProps.placeholder;
|
|
360
235
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (['Switch', 'SwitchCheckbox'].includes(type)) {
|
|
364
|
-
formItemProps.valuePropName = 'checked';
|
|
236
|
+
if (["Switch", "SwitchCheckbox"].includes(type)) {
|
|
237
|
+
formItemProps.valuePropName = "checked";
|
|
365
238
|
}
|
|
366
|
-
|
|
367
|
-
// 分离 transform 中的 normalize 和 getValueProps(这些应该应用到 Form.Item,而不是组件)
|
|
368
|
-
const {
|
|
369
|
-
normalize,
|
|
370
|
-
getValueProps,
|
|
371
|
-
...restTransform
|
|
372
|
-
} = transform || {};
|
|
373
|
-
|
|
374
|
-
// formItemTransform 只包含应该应用到 Form.Item 的属性
|
|
239
|
+
const { normalize, getValueProps, ...restTransform } = transform || {};
|
|
375
240
|
const formItemTransform = {
|
|
376
|
-
...
|
|
377
|
-
|
|
378
|
-
}),
|
|
379
|
-
...(getValueProps && {
|
|
380
|
-
getValueProps
|
|
381
|
-
})
|
|
241
|
+
...normalize && { normalize },
|
|
242
|
+
...getValueProps && { getValueProps }
|
|
382
243
|
};
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
244
|
+
const filteredComponentProps = omit(
|
|
245
|
+
{
|
|
246
|
+
...componentProps,
|
|
247
|
+
...restTransform
|
|
248
|
+
},
|
|
249
|
+
[
|
|
250
|
+
"valueType",
|
|
251
|
+
"switchValue",
|
|
252
|
+
"toISOString",
|
|
253
|
+
"toCSTString",
|
|
254
|
+
"format",
|
|
255
|
+
"precision",
|
|
256
|
+
"clearNotShow",
|
|
257
|
+
"dependNames"
|
|
258
|
+
]
|
|
259
|
+
);
|
|
389
260
|
return {
|
|
390
261
|
componentProps: filteredComponentProps,
|
|
391
262
|
formItemTransform
|
|
392
263
|
};
|
|
393
264
|
};
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* 配置验证组件
|
|
397
|
-
*/
|
|
398
|
-
export const validateChildren = children => {
|
|
399
|
-
// 确保children是数组
|
|
265
|
+
const validateChildren = (children) => {
|
|
400
266
|
if (!Array.isArray(children) || children.length === 0) {
|
|
401
|
-
console.warn(
|
|
267
|
+
console.warn("[ProForm Group] 灵活模式下children必须是数组且不能为空");
|
|
402
268
|
return false;
|
|
403
269
|
}
|
|
404
|
-
const invalidChildren = children.filter(child => {
|
|
405
|
-
return child.names || !child.name || child.type ===
|
|
270
|
+
const invalidChildren = children.filter((child) => {
|
|
271
|
+
return child.names || !child.name || child.type === "Group";
|
|
406
272
|
});
|
|
407
273
|
if (invalidChildren.length > 0) {
|
|
408
|
-
console.warn(
|
|
274
|
+
console.warn(
|
|
275
|
+
"[ProForm Group] 灵活模式下所有子组件都必须配置name属性。且type不能为Group",
|
|
276
|
+
"缺少name的组件索引:",
|
|
277
|
+
invalidChildren.map(
|
|
278
|
+
(_, index) => children.findIndex((child) => child === invalidChildren[index])
|
|
279
|
+
),
|
|
280
|
+
"\n示例配置:",
|
|
281
|
+
'\n{\n type: "InputNumber",\n name: "min", // 必需\n rules: [...] // 可选\n}'
|
|
282
|
+
);
|
|
409
283
|
return false;
|
|
410
284
|
}
|
|
411
|
-
|
|
412
|
-
// 检查name重复
|
|
413
|
-
const names = children.map(child => child.name);
|
|
285
|
+
const names = children.map((child) => child.name);
|
|
414
286
|
const duplicateNames = names.filter((name, index) => names.indexOf(name) !== index);
|
|
415
287
|
if (duplicateNames.length > 0) {
|
|
416
|
-
console.warn(
|
|
288
|
+
console.warn("[ProForm Group] 子组件中发现重复的name属性:", [...new Set(duplicateNames)]);
|
|
417
289
|
return false;
|
|
418
290
|
}
|
|
419
291
|
return true;
|
|
420
|
-
};
|
|
292
|
+
};
|
|
293
|
+
export {
|
|
294
|
+
createComponentProps,
|
|
295
|
+
defaultGetValueFromEvent,
|
|
296
|
+
getReactiveProps,
|
|
297
|
+
getValueMiddleware,
|
|
298
|
+
getValueTypeTrans,
|
|
299
|
+
insertSeparator,
|
|
300
|
+
isUpperCase,
|
|
301
|
+
transformNamesString,
|
|
302
|
+
useFormItemProps,
|
|
303
|
+
validateChildren,
|
|
304
|
+
valueFromEventWrapper
|
|
305
|
+
};
|