@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,10 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState, memo, useMemo, useCallback } from "react";
|
|
3
|
+
import { Cascader, Tooltip, message } from "antd";
|
|
4
|
+
import omit from "lodash/omit";
|
|
5
|
+
import _find from "lodash/find";
|
|
6
|
+
import isBoolean from "lodash/isBoolean";
|
|
7
|
+
import isEqual from "lodash/isEqual";
|
|
8
|
+
import { useRequest as useRequestFunc, useDeepCompareEffect } from "ahooks";
|
|
8
9
|
import { transformDataName } from "./utils/index";
|
|
9
10
|
import { useProConfig } from "../../../../ProConfigProvider";
|
|
10
11
|
import Input from "../../base/Input";
|
|
@@ -12,48 +13,39 @@ import useEnum from "../../../../ProEnum/hooks/useEnum";
|
|
|
12
13
|
import locale from "../../../../locale";
|
|
13
14
|
import ProForm from "../../..";
|
|
14
15
|
import Container from "../../Container";
|
|
15
|
-
|
|
16
|
-
const defaultFieldNames = {
|
|
17
|
-
label: 'name',
|
|
18
|
-
value: 'code',
|
|
19
|
-
children: 'children'
|
|
20
|
-
};
|
|
16
|
+
const defaultFieldNames = { label: "name", value: "code", children: "children" };
|
|
21
17
|
const filterDataSource = (dataSource, level, fieldNames) => {
|
|
22
|
-
return dataSource
|
|
18
|
+
return dataSource == null ? void 0 : dataSource.map((item) => ({
|
|
23
19
|
...item,
|
|
24
|
-
[fieldNames
|
|
20
|
+
[(fieldNames == null ? void 0 : fieldNames.children) || "children"]: level === 1 ? [] : filterDataSource(item == null ? void 0 : item[(fieldNames == null ? void 0 : fieldNames.children) || "children"], level - 1, fieldNames)
|
|
25
21
|
}));
|
|
26
22
|
};
|
|
27
|
-
const getViewLabel = ({
|
|
28
|
-
dataSource,
|
|
29
|
-
value
|
|
30
|
-
}) => {
|
|
23
|
+
const getViewLabel = ({ dataSource, value }) => {
|
|
31
24
|
let _value = value;
|
|
32
25
|
const viewLabel = [];
|
|
33
|
-
// fix: value是string类型,需要转为数组
|
|
34
26
|
if (_value && !Array.isArray(_value)) {
|
|
35
27
|
_value = [value];
|
|
36
28
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
viewLabel[index] = temp?.label;
|
|
29
|
+
_value == null ? void 0 : _value.forEach((value2, index) => {
|
|
30
|
+
const temp = dataSource == null ? void 0 : dataSource.find((item) => (item == null ? void 0 : item.value) === value2);
|
|
31
|
+
dataSource = (temp == null ? void 0 : temp.children) || [];
|
|
32
|
+
viewLabel[index] = temp == null ? void 0 : temp.label;
|
|
42
33
|
});
|
|
43
34
|
return viewLabel;
|
|
44
35
|
};
|
|
45
|
-
const ProCascader = props => {
|
|
46
|
-
|
|
47
|
-
const
|
|
36
|
+
const ProCascader = (props) => {
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
38
|
+
const proCascaderConfig = useProConfig("ProCascader");
|
|
39
|
+
const proAddressBarConfig = useProConfig("ProAddressBar");
|
|
48
40
|
const {
|
|
49
41
|
detailMaxLength: configDetailMaxLength,
|
|
50
42
|
enumCode: configEnumCode,
|
|
51
43
|
code: configCode
|
|
52
44
|
} = proCascaderConfig ?? proAddressBarConfig ?? {};
|
|
53
|
-
const isAddressMode = props
|
|
45
|
+
const isAddressMode = (props == null ? void 0 : props.mode) === "address" || ((_a = props == null ? void 0 : props.otherProps) == null ? void 0 : _a.type) === "ProAddressBar";
|
|
54
46
|
const {
|
|
55
|
-
className =
|
|
56
|
-
hasDetail = isAddressMode ? true :
|
|
47
|
+
className = "",
|
|
48
|
+
hasDetail = isAddressMode ? true : void 0,
|
|
57
49
|
detailMaxLength = isAddressMode ? configDetailMaxLength || 100 : 100,
|
|
58
50
|
fieldNames = defaultFieldNames,
|
|
59
51
|
value,
|
|
@@ -63,57 +55,49 @@ const ProCascader = props => {
|
|
|
63
55
|
useRequest,
|
|
64
56
|
transformResponse,
|
|
65
57
|
// 地址组件需要传入level来判断detail的值放在数组的索引
|
|
66
|
-
level = isAddressMode ? 3 :
|
|
58
|
+
level = isAddressMode ? 3 : void 0,
|
|
67
59
|
isView,
|
|
68
60
|
enumCode = configEnumCode,
|
|
69
61
|
code = configCode,
|
|
70
62
|
tooltip,
|
|
71
|
-
separator =
|
|
63
|
+
separator = "/",
|
|
72
64
|
detailPlaceholder,
|
|
73
65
|
scrollFollowParent,
|
|
74
66
|
desensitization,
|
|
75
67
|
otherProps,
|
|
76
68
|
...restProps
|
|
77
69
|
} = props;
|
|
78
|
-
const {
|
|
79
|
-
isView: isViewCon,
|
|
80
|
-
viewEmpty
|
|
81
|
-
} = ProForm.useFieldProps() || {};
|
|
70
|
+
const { isView: isViewCon, viewEmpty } = ProForm.useFieldProps() || {};
|
|
82
71
|
const addressCode = code || enumCode;
|
|
83
|
-
const realIsView = typeof isView ===
|
|
72
|
+
const realIsView = typeof isView === "boolean" ? isView : isViewCon;
|
|
84
73
|
const realLevel = level || 2;
|
|
85
|
-
const detail = value
|
|
74
|
+
const detail = value == null ? void 0 : value[realLevel];
|
|
86
75
|
const enumData = useEnum(addressCode);
|
|
87
|
-
const {
|
|
88
|
-
dics = {}
|
|
89
|
-
} = useProConfig('ProEnum');
|
|
76
|
+
const { dics = {} } = useProConfig("ProEnum");
|
|
90
77
|
const enumDataSource = useMemo(() => {
|
|
91
|
-
if (!props
|
|
92
|
-
return dics
|
|
78
|
+
if (!(props == null ? void 0 : props.mode)) {
|
|
79
|
+
return (dics == null ? void 0 : dics[addressCode]) || [];
|
|
93
80
|
}
|
|
94
81
|
return Array.isArray(enumData) ? enumData[0] : [];
|
|
95
|
-
}, [dics
|
|
82
|
+
}, [dics == null ? void 0 : dics[addressCode], enumData]);
|
|
96
83
|
let realDataSource = useMemo(() => {
|
|
97
84
|
const innerDataSource = dataSource || (addressCode ? enumDataSource : []);
|
|
98
|
-
const result = transformDataName(
|
|
85
|
+
const result = transformDataName(
|
|
86
|
+
isAddressMode && realLevel < 3 ? filterDataSource(innerDataSource, level, fieldNames) : innerDataSource,
|
|
87
|
+
fieldNames
|
|
88
|
+
);
|
|
99
89
|
return result;
|
|
100
|
-
}, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource
|
|
90
|
+
}, [isAddressMode, addressCode, realLevel, dataSource, enumDataSource == null ? void 0 : enumDataSource.length]);
|
|
101
91
|
const lastDisabled = useMemo(() => {
|
|
102
|
-
if (
|
|
92
|
+
if (isBoolean(disabled) || disabled === void 0) {
|
|
103
93
|
return [disabled, disabled];
|
|
104
94
|
}
|
|
105
95
|
return disabled;
|
|
106
96
|
}, [disabled]);
|
|
107
97
|
const [serviceData, setServiceData] = useState([]);
|
|
108
98
|
const [defaultLabel, setDefaultLabel] = useState([]);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const defaultOnSuccessFun = res => {
|
|
112
|
-
const {
|
|
113
|
-
status = 200,
|
|
114
|
-
message: msg,
|
|
115
|
-
data
|
|
116
|
-
} = res || {};
|
|
99
|
+
const defaultOnSuccessFun = (res) => {
|
|
100
|
+
const { status = 200, message: msg, data } = res || {};
|
|
117
101
|
if (status !== 200) {
|
|
118
102
|
message.error(msg);
|
|
119
103
|
return;
|
|
@@ -125,106 +109,93 @@ const ProCascader = props => {
|
|
|
125
109
|
const transFormData = transformDataName(newData, {
|
|
126
110
|
label: fieldNames.label,
|
|
127
111
|
value: fieldNames.value,
|
|
128
|
-
children: fieldNames
|
|
112
|
+
children: (fieldNames == null ? void 0 : fieldNames.children) || "children"
|
|
129
113
|
});
|
|
130
|
-
const
|
|
131
|
-
setServiceData(
|
|
114
|
+
const serviceData2 = isAddressMode && realLevel < 3 ? filterDataSource(transFormData, level, fieldNames) : transFormData;
|
|
115
|
+
setServiceData(serviceData2);
|
|
132
116
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return data;
|
|
149
|
-
}, [transformResponse]);
|
|
150
|
-
|
|
151
|
-
// 使用ahooks的useRequest
|
|
152
|
-
const fetchFunction = useRequestFunc(useRequest?.service, {
|
|
117
|
+
const successTransformDataHandle = useCallback(
|
|
118
|
+
(res) => {
|
|
119
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
120
|
+
return transformResponse(res);
|
|
121
|
+
}
|
|
122
|
+
const { status = 200, message: msg, data } = res || {};
|
|
123
|
+
if (status !== 200) {
|
|
124
|
+
message.error(msg);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
return data;
|
|
128
|
+
},
|
|
129
|
+
[transformResponse]
|
|
130
|
+
);
|
|
131
|
+
const fetchFunction = useRequestFunc(useRequest == null ? void 0 : useRequest.service, {
|
|
153
132
|
manual: true,
|
|
154
133
|
debounceWait: 300,
|
|
155
|
-
...useRequest
|
|
156
|
-
onSuccess: data => {
|
|
157
|
-
|
|
134
|
+
...useRequest == null ? void 0 : useRequest.options,
|
|
135
|
+
onSuccess: (data) => {
|
|
136
|
+
var _a2, _b2, _c2;
|
|
137
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
158
138
|
const responseData = transformResponse(data);
|
|
159
139
|
const transFormData = transformDataName(responseData, {
|
|
160
140
|
label: fieldNames.label,
|
|
161
141
|
value: fieldNames.value,
|
|
162
|
-
children: fieldNames
|
|
142
|
+
children: (fieldNames == null ? void 0 : fieldNames.children) || "children"
|
|
163
143
|
});
|
|
164
|
-
const
|
|
165
|
-
setServiceData(
|
|
144
|
+
const serviceData2 = isAddressMode && realLevel < 3 ? filterDataSource(transFormData, level, fieldNames) : transFormData;
|
|
145
|
+
setServiceData(serviceData2);
|
|
166
146
|
} else {
|
|
167
147
|
defaultOnSuccessFun(data);
|
|
168
148
|
}
|
|
169
|
-
|
|
170
|
-
useRequest?.options?.onSuccess?.(data, useRequest?.options?.defaultParams);
|
|
149
|
+
(_c2 = (_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.onSuccess) == null ? void 0 : _c2.call(_a2, data, (_b2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _b2.defaultParams);
|
|
171
150
|
}
|
|
172
151
|
});
|
|
173
|
-
|
|
174
|
-
// 缓存数据处理
|
|
175
|
-
const cacheList = useRequest?.options?.cacheKey ? successTransformDataHandle(fetchFunction?.data) : [];
|
|
176
|
-
|
|
177
|
-
// 提取出来默认每次都执行
|
|
152
|
+
const cacheList = ((_b = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _b.cacheKey) ? successTransformDataHandle(fetchFunction == null ? void 0 : fetchFunction.data) : [];
|
|
178
153
|
if (transformResponse) {
|
|
179
154
|
realDataSource = transformResponse(realDataSource);
|
|
180
155
|
}
|
|
181
|
-
|
|
182
|
-
// 设置缓存数据
|
|
183
156
|
useDeepCompareEffect(() => {
|
|
184
|
-
|
|
185
|
-
|
|
157
|
+
var _a2;
|
|
158
|
+
if (!(serviceData == null ? void 0 : serviceData.length) && ((_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.cacheKey)) {
|
|
159
|
+
if (cacheList == null ? void 0 : cacheList.length) {
|
|
186
160
|
setServiceData(cacheList);
|
|
187
161
|
}
|
|
188
162
|
}
|
|
189
|
-
}, [fetchFunction
|
|
190
|
-
|
|
191
|
-
// 初始化请求数据
|
|
163
|
+
}, [fetchFunction == null ? void 0 : fetchFunction.data]);
|
|
192
164
|
useDeepCompareEffect(() => {
|
|
193
|
-
|
|
165
|
+
var _a2;
|
|
166
|
+
if (!(useRequest == null ? void 0 : useRequest.service)) {
|
|
194
167
|
return;
|
|
195
168
|
}
|
|
196
|
-
const {
|
|
197
|
-
|
|
198
|
-
} = useRequest?.options || {};
|
|
199
|
-
if (manual || cacheList?.length) {
|
|
169
|
+
const { manual } = (useRequest == null ? void 0 : useRequest.options) || {};
|
|
170
|
+
if (manual || (cacheList == null ? void 0 : cacheList.length)) {
|
|
200
171
|
return;
|
|
201
172
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const defaultParams = useRequest?.options?.defaultParams || useRequest?.defaultParams;
|
|
205
|
-
const params = Array.isArray(defaultParams) ? defaultParams?.[0] : defaultParams || {};
|
|
173
|
+
const defaultParams = ((_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.defaultParams) || (useRequest == null ? void 0 : useRequest.defaultParams);
|
|
174
|
+
const params = Array.isArray(defaultParams) ? defaultParams == null ? void 0 : defaultParams[0] : defaultParams || {};
|
|
206
175
|
fetchFunction.run(params);
|
|
207
|
-
}, [useRequest
|
|
176
|
+
}, [useRequest == null ? void 0 : useRequest.options]);
|
|
208
177
|
useEffect(() => {
|
|
209
178
|
if (realIsView && value) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
179
|
+
if (useRequest == null ? void 0 : useRequest.service) {
|
|
180
|
+
setDefaultLabel(
|
|
181
|
+
getViewLabel({
|
|
182
|
+
dataSource: serviceData,
|
|
183
|
+
value: isAddressMode && hasDetail ? value == null ? void 0 : value.slice(0, realLevel) : value
|
|
184
|
+
})
|
|
185
|
+
);
|
|
186
|
+
} else if ((realDataSource == null ? void 0 : realDataSource.length) > 0) {
|
|
187
|
+
setDefaultLabel(
|
|
188
|
+
getViewLabel({
|
|
189
|
+
dataSource: realDataSource,
|
|
190
|
+
value: isAddressMode && hasDetail ? value == null ? void 0 : value.slice(0, realLevel) : value
|
|
191
|
+
})
|
|
192
|
+
);
|
|
221
193
|
}
|
|
222
194
|
}
|
|
223
195
|
}, [realIsView, value, realDataSource, serviceData]);
|
|
224
196
|
const handleChange = (changeValue, selectedOptions) => {
|
|
225
197
|
if (onChange) {
|
|
226
198
|
if (isAddressMode && hasDetail && detail) {
|
|
227
|
-
// 有详情地址
|
|
228
199
|
const realValue = changeValue || [];
|
|
229
200
|
realValue[realLevel] = detail;
|
|
230
201
|
onChange(realValue, selectedOptions);
|
|
@@ -233,54 +204,42 @@ const ProCascader = props => {
|
|
|
233
204
|
}
|
|
234
205
|
}
|
|
235
206
|
};
|
|
236
|
-
|
|
237
|
-
// showSearch中的筛选函数
|
|
238
207
|
const handlefilter = (inputValue, path) => {
|
|
239
|
-
return path.some(option => {
|
|
208
|
+
return path.some((option) => {
|
|
240
209
|
return option.label.toLowerCase().indexOf(inputValue.toLowerCase()) > -1;
|
|
241
210
|
});
|
|
242
211
|
};
|
|
243
|
-
const displayRender = label => {
|
|
244
|
-
return label
|
|
212
|
+
const displayRender = (label) => {
|
|
213
|
+
return label == null ? void 0 : label.filter((item) => !!item).join("/");
|
|
245
214
|
};
|
|
246
|
-
const addressValue = isAddressMode ? value && value.slice(0, realLevel)
|
|
247
|
-
const viewValue = isAddressMode ? [...defaultLabel, value
|
|
248
|
-
const findSelectedOptions = (options,
|
|
249
|
-
const _value =
|
|
250
|
-
|
|
251
|
-
if (_value?.length === 0 && path?.length > 0) {
|
|
215
|
+
const addressValue = isAddressMode ? value && ((_c = value.slice(0, realLevel)) == null ? void 0 : _c.some((item) => !!item)) ? value.slice(0, realLevel) : void 0 : value;
|
|
216
|
+
const viewValue = isAddressMode ? ((_e = (_d = [...defaultLabel, value == null ? void 0 : value[realLevel]]) == null ? void 0 : _d.filter((item) => !!item)) == null ? void 0 : _e.join(separator)) || "-" : ((_f = defaultLabel == null ? void 0 : defaultLabel.filter((item) => !!item)) == null ? void 0 : _f.join(separator)) || "-";
|
|
217
|
+
const findSelectedOptions = (options, value2, path = []) => {
|
|
218
|
+
const _value = value2 ?? [];
|
|
219
|
+
if ((_value == null ? void 0 : _value.length) === 0 && (path == null ? void 0 : path.length) > 0) {
|
|
252
220
|
return path;
|
|
253
221
|
}
|
|
254
|
-
|
|
255
|
-
// 如果没有更多的 _value 需要匹配,或者当前选项没有 children,返回 null
|
|
256
|
-
if (_value?.length === 0 || !options || options.length === 0) {
|
|
222
|
+
if ((_value == null ? void 0 : _value.length) === 0 || !options || options.length === 0) {
|
|
257
223
|
return null;
|
|
258
224
|
}
|
|
259
|
-
|
|
260
|
-
// 尝试在当前层级的选项中查找匹配的 _value
|
|
261
225
|
const currentValue = _value[0];
|
|
262
|
-
const foundOption =
|
|
263
|
-
value: currentValue
|
|
264
|
-
});
|
|
226
|
+
const foundOption = _find(options, { value: currentValue });
|
|
265
227
|
if (foundOption) {
|
|
266
|
-
// 如果找到了匹配的选项,并且还有更多的 value 需要匹配,递归地在子选项中查找
|
|
267
228
|
if (_value.length > 1 && foundOption.children) {
|
|
268
229
|
return findSelectedOptions(foundOption.children, _value.slice(1), [...path, foundOption]);
|
|
269
230
|
}
|
|
270
|
-
// 如果没有更多的 value 需要匹配,返回当前选项(以及之前的路径)
|
|
271
231
|
return [...path, foundOption];
|
|
272
232
|
}
|
|
273
|
-
// 如果没有在当前层级的选项中找到匹配的 value,返回 null
|
|
274
233
|
return null;
|
|
275
234
|
};
|
|
276
235
|
const _selectedOptions = useMemo(() => {
|
|
277
|
-
return findSelectedOptions(useRequest
|
|
278
|
-
}, [useRequest
|
|
279
|
-
const handleAddressChange = e => {
|
|
280
|
-
const cascaderValue = value
|
|
236
|
+
return findSelectedOptions((useRequest == null ? void 0 : useRequest.service) ? serviceData : realDataSource, addressValue);
|
|
237
|
+
}, [useRequest == null ? void 0 : useRequest.service, serviceData, realDataSource, addressValue]);
|
|
238
|
+
const handleAddressChange = (e) => {
|
|
239
|
+
const cascaderValue = value == null ? void 0 : value.slice(0, realLevel);
|
|
281
240
|
if (onChange) {
|
|
282
|
-
if (!e.target.value && cascaderValue
|
|
283
|
-
onChange(
|
|
241
|
+
if (!e.target.value && (cascaderValue == null ? void 0 : cascaderValue.every((item) => !item))) {
|
|
242
|
+
onChange(void 0);
|
|
284
243
|
} else {
|
|
285
244
|
const realValue = value ? [...value] : [];
|
|
286
245
|
realValue[realLevel] = e.target.value;
|
|
@@ -288,57 +247,55 @@ const ProCascader = props => {
|
|
|
288
247
|
}
|
|
289
248
|
}
|
|
290
249
|
};
|
|
291
|
-
return realIsView ?
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
desensitization: desensitization,
|
|
334
|
-
otherProps: otherProps
|
|
335
|
-
}))]
|
|
336
|
-
});
|
|
250
|
+
return realIsView ? /* @__PURE__ */ jsx(Container, { tooltip: !!tooltip, viewEmpty, children: viewValue }) : /* @__PURE__ */ jsxs("div", { className: `pro-address ${className}`, children: [
|
|
251
|
+
/* @__PURE__ */ jsx(
|
|
252
|
+
Cascader,
|
|
253
|
+
{
|
|
254
|
+
className: hasDetail ? "" : "no-detail",
|
|
255
|
+
placeholder: (_h = (_g = locale) == null ? void 0 : _g.ProAddressBar) == null ? void 0 : _h.placeholder,
|
|
256
|
+
value: addressValue,
|
|
257
|
+
options: (useRequest == null ? void 0 : useRequest.service) ? serviceData : realDataSource,
|
|
258
|
+
disabled: lastDisabled[0],
|
|
259
|
+
loading: fetchFunction == null ? void 0 : fetchFunction.loading,
|
|
260
|
+
displayRender,
|
|
261
|
+
showSearch: { filter: handlefilter, limit: 1e3 },
|
|
262
|
+
onChange: handleChange,
|
|
263
|
+
getPopupContainer: (trigger) => {
|
|
264
|
+
return scrollFollowParent ? trigger.parentElement : document.body;
|
|
265
|
+
},
|
|
266
|
+
...omit(restProps, ["otherProps", "scrollFollowParent"])
|
|
267
|
+
}
|
|
268
|
+
),
|
|
269
|
+
hasDetail && (tooltip && lastDisabled[1] && detail ? /* @__PURE__ */ jsx(Tooltip, { title: detail, children: /* @__PURE__ */ jsx("span", { className: "pro-address-detail", children: /* @__PURE__ */ jsx(
|
|
270
|
+
Input,
|
|
271
|
+
{
|
|
272
|
+
disabled: lastDisabled[1],
|
|
273
|
+
desensitization,
|
|
274
|
+
otherProps,
|
|
275
|
+
value: detail
|
|
276
|
+
}
|
|
277
|
+
) }) }) : /* @__PURE__ */ jsx(
|
|
278
|
+
Input,
|
|
279
|
+
{
|
|
280
|
+
allowClear: true,
|
|
281
|
+
autoComplete: "off",
|
|
282
|
+
disabled: lastDisabled[1],
|
|
283
|
+
value: detail,
|
|
284
|
+
maxLength: detailMaxLength,
|
|
285
|
+
placeholder: detailPlaceholder || ((_j = (_i = locale) == null ? void 0 : _i.ProAddressBar) == null ? void 0 : _j.detailPlaceholder),
|
|
286
|
+
onChange: handleAddressChange,
|
|
287
|
+
desensitization,
|
|
288
|
+
otherProps
|
|
289
|
+
}
|
|
290
|
+
))
|
|
291
|
+
] });
|
|
337
292
|
};
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (!_isEqual(prevProps?.value, nextProps?.value) || prevProps?.disabled !== nextProps?.disabled || !_isEqual(prevProps?.dataSource, nextProps?.dataSource)) {
|
|
293
|
+
var ProCascader_default = memo(ProCascader, (prevProps, nextProps) => {
|
|
294
|
+
if (!isEqual(prevProps == null ? void 0 : prevProps.value, nextProps == null ? void 0 : nextProps.value) || (prevProps == null ? void 0 : prevProps.disabled) !== (nextProps == null ? void 0 : nextProps.disabled) || !isEqual(prevProps == null ? void 0 : prevProps.dataSource, nextProps == null ? void 0 : nextProps.dataSource)) {
|
|
341
295
|
return false;
|
|
342
296
|
}
|
|
343
297
|
return true;
|
|
344
|
-
});
|
|
298
|
+
});
|
|
299
|
+
export {
|
|
300
|
+
ProCascader_default as default
|
|
301
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
|
|
5
|
-
value,
|
|
6
|
-
children,
|
|
7
|
-
...extraFields
|
|
8
|
-
} = fieldNames;
|
|
9
|
-
if (!dataSource?.length || 'label' in dataSource[0] && 'value' in dataSource[0] && 'children' in dataSource[0]) {
|
|
1
|
+
import omit from "lodash/omit";
|
|
2
|
+
const transformDataName = (dataSource, fieldNames) => {
|
|
3
|
+
const { label, value, children, ...extraFields } = fieldNames;
|
|
4
|
+
if (!(dataSource == null ? void 0 : dataSource.length) || "label" in dataSource[0] && "value" in dataSource[0] && "children" in dataSource[0]) {
|
|
10
5
|
return dataSource;
|
|
11
6
|
}
|
|
12
7
|
function transformNode(node) {
|
|
13
|
-
const newNode = {
|
|
14
|
-
|
|
15
|
-
value: node[value]
|
|
16
|
-
};
|
|
17
|
-
// 处理额外的字段
|
|
18
|
-
Object.keys(extraFields).forEach(key => {
|
|
8
|
+
const newNode = { label: node[label], value: node[value] };
|
|
9
|
+
Object.keys(extraFields).forEach((key) => {
|
|
19
10
|
newNode[key] = node[extraFields[key]];
|
|
20
11
|
});
|
|
21
12
|
if (children && Array.isArray(node[children])) {
|
|
22
13
|
newNode.children = node[children].map(transformNode);
|
|
23
14
|
}
|
|
24
|
-
return {
|
|
25
|
-
...newNode,
|
|
26
|
-
..._omit(node, Object.values(fieldNames))
|
|
27
|
-
};
|
|
15
|
+
return { ...newNode, ...omit(node, Object.values(fieldNames)) };
|
|
28
16
|
}
|
|
29
|
-
const transformData = data => {
|
|
17
|
+
const transformData = (data) => {
|
|
30
18
|
return data.map(transformNode);
|
|
31
19
|
};
|
|
32
20
|
return transformData(dataSource);
|
|
33
|
-
};
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
transformDataName
|
|
24
|
+
};
|