@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,30 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { tools } from
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useImperativeHandle, forwardRef, useCallback } from "react";
|
|
3
|
+
import { useDeepCompareEffect, useRequest as useRequestFunc, useSetState } from "ahooks";
|
|
4
|
+
import { Input, TreeSelect, message, Tooltip } from "antd";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
7
|
+
import debounce from "lodash/debounce";
|
|
8
|
+
import { tools } from "@zat-design/utils";
|
|
9
9
|
import locale from "../../../locale";
|
|
10
10
|
import { useProConfig } from "../../../ProConfigProvider";
|
|
11
11
|
import Container from "../../../ProForm/components/Container";
|
|
12
12
|
import AdaptiveTooltip from "../AdaptiveTooltip";
|
|
13
13
|
import { getFlatTreeData, restoreCodeNameLabel, applyCheckLeaf } from "../../utils";
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
} =
|
|
18
|
-
|
|
19
|
-
// 全局属性配置在ConfigProvider
|
|
20
|
-
const {
|
|
21
|
-
fieldNames: proSelectFieldNames = {}
|
|
22
|
-
} = useProConfig('ProTreeSelect') || {};
|
|
23
|
-
const {
|
|
24
|
-
dics = {}
|
|
25
|
-
} = useProConfig('ProEnum');
|
|
26
|
-
|
|
27
|
-
// 配置属性
|
|
14
|
+
const { SHOW_PARENT } = TreeSelect;
|
|
15
|
+
const ProTreeSelect = (props, ref) => {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f;
|
|
17
|
+
const { fieldNames: proSelectFieldNames = {} } = useProConfig("ProTreeSelect") || {};
|
|
18
|
+
const { dics = {} } = useProConfig("ProEnum");
|
|
28
19
|
const {
|
|
29
20
|
disabled,
|
|
30
21
|
code: enumCode,
|
|
@@ -43,7 +34,7 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
43
34
|
// 默认支持搜索
|
|
44
35
|
filterTreeNode,
|
|
45
36
|
// 是否根据输入项进行筛选,默认true
|
|
46
|
-
treeNodeFilterProp =
|
|
37
|
+
treeNodeFilterProp = "label",
|
|
47
38
|
defaultExpandAll = true,
|
|
48
39
|
// 默认展开所有树
|
|
49
40
|
expandedKeys,
|
|
@@ -67,84 +58,46 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
67
58
|
// 开启后只能选择叶子节点,非叶子节点置灰禁用
|
|
68
59
|
...selectProps
|
|
69
60
|
} = props;
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
} =
|
|
73
|
-
const {
|
|
74
|
-
showEllipse = true
|
|
75
|
-
} = props;
|
|
76
|
-
const {
|
|
77
|
-
isDiffChange
|
|
78
|
-
} = otherProps ?? {};
|
|
61
|
+
const { value = void 0 } = props;
|
|
62
|
+
const { showEllipse = true } = props;
|
|
63
|
+
const { isDiffChange } = otherProps ?? {};
|
|
79
64
|
const _showEllipse = showEllipse && !isDiffChange;
|
|
80
|
-
const {
|
|
81
|
-
isView,
|
|
82
|
-
viewEmpty
|
|
83
|
-
} = otherProps || {};
|
|
84
|
-
|
|
85
|
-
// 合并全局和组件级别的 fieldNames,优先级:组件级 > 全局
|
|
65
|
+
const { isView, viewEmpty } = otherProps || {};
|
|
86
66
|
const finalFieldNames = {
|
|
87
|
-
label:
|
|
88
|
-
value:
|
|
89
|
-
children:
|
|
67
|
+
label: "label",
|
|
68
|
+
value: "value",
|
|
69
|
+
children: "children",
|
|
90
70
|
...proSelectFieldNames,
|
|
91
71
|
...fieldNames
|
|
92
72
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return tools.transformDataName(data, {
|
|
107
|
-
label: finalFieldNames.label,
|
|
108
|
-
value: finalFieldNames.value,
|
|
109
|
-
children: finalFieldNames.children
|
|
110
|
-
});
|
|
111
|
-
}, [finalFieldNames]);
|
|
112
|
-
// 经过处理后的枚举数据,可能来自用户配置的处理函数后返回的结果
|
|
73
|
+
const transformFieldNames = useCallback(
|
|
74
|
+
(data) => {
|
|
75
|
+
if (!data || !Array.isArray(data) || !data.length) {
|
|
76
|
+
return data || [];
|
|
77
|
+
}
|
|
78
|
+
return tools.transformDataName(data, {
|
|
79
|
+
label: finalFieldNames.label,
|
|
80
|
+
value: finalFieldNames.value,
|
|
81
|
+
children: finalFieldNames.children
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
[finalFieldNames]
|
|
85
|
+
);
|
|
113
86
|
const [state, setState] = useSetState({});
|
|
114
|
-
const {
|
|
115
|
-
|
|
116
|
-
origDataSource = []
|
|
117
|
-
} = state;
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 如果数据少于10条那么将数据平铺返回
|
|
121
|
-
* 注意:当 treeCheckable 为 false 时(单选模式),应保持树形结构,不进行平铺
|
|
122
|
-
* @param dictsEnum 原始数据
|
|
123
|
-
* @returns 平铺或者原始数据
|
|
124
|
-
*/
|
|
125
|
-
const countChild = dictsEnum => {
|
|
87
|
+
const { selectList = [], origDataSource = [] } = state;
|
|
88
|
+
const countChild = (dictsEnum) => {
|
|
126
89
|
if (treeCheckable) {
|
|
127
90
|
return dictsEnum;
|
|
128
91
|
}
|
|
129
|
-
// 单选模式(treeCheckable=false)时,保持树形结构,不进行平铺
|
|
130
|
-
// 因为 TreeSelect 在单选模式下也需要树形结构来正确展示层级关系
|
|
131
92
|
return dictsEnum;
|
|
132
93
|
};
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* 如果要展示code-name,那么将源数据的label转为code-name
|
|
136
|
-
* 注意:此时数据已经是标准格式(label, value, children)
|
|
137
|
-
* @param dataArr 源数据(标准格式)
|
|
138
|
-
* @param showCodeAndName 是否展示code-name
|
|
139
|
-
* @returns 转换结果
|
|
140
|
-
*/
|
|
141
94
|
const transferDataSource = (dataArr, showCodeAndName) => {
|
|
142
95
|
if (!showCodeAndName) {
|
|
143
96
|
return dataArr;
|
|
144
97
|
}
|
|
145
|
-
const copyData =
|
|
146
|
-
const loop = arr => {
|
|
147
|
-
arr.map(item => {
|
|
98
|
+
const copyData = cloneDeep(dataArr);
|
|
99
|
+
const loop = (arr) => {
|
|
100
|
+
arr.map((item) => {
|
|
148
101
|
item.label = `${item.value}-${item.label}`;
|
|
149
102
|
if (item.children) {
|
|
150
103
|
loop(item.children);
|
|
@@ -155,162 +108,104 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
155
108
|
loop(copyData);
|
|
156
109
|
return copyData;
|
|
157
110
|
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* 统一数据后处理:先处理 code-name 展示,再按 checkLeaf 标记非叶子节点禁用
|
|
161
|
-
* 数据已是标准格式(label, value, children)
|
|
162
|
-
* @param dataArr 标准格式数据
|
|
163
|
-
* @returns 后处理结果
|
|
164
|
-
*/
|
|
165
|
-
const processData = dataArr => {
|
|
111
|
+
const processData = (dataArr) => {
|
|
166
112
|
const result = transferDataSource(dataArr, showCodeName);
|
|
167
113
|
return checkLeaf ? applyCheckLeaf(result) : result;
|
|
168
114
|
};
|
|
169
|
-
const defaultOnSuccessFun = res => {
|
|
170
|
-
const {
|
|
171
|
-
status = 200,
|
|
172
|
-
message: msg,
|
|
173
|
-
data
|
|
174
|
-
} = res;
|
|
115
|
+
const defaultOnSuccessFun = (res) => {
|
|
116
|
+
const { status = 200, message: msg, data } = res;
|
|
175
117
|
if (status !== 200) {
|
|
176
118
|
message.error(msg);
|
|
177
119
|
return;
|
|
178
120
|
}
|
|
179
|
-
// 先转换字段名,再处理 code-name 展示与 checkLeaf 标记
|
|
180
121
|
const transformedData = transformFieldNames(data || []);
|
|
181
122
|
const resultData = processData(transformedData);
|
|
182
|
-
setState({
|
|
183
|
-
selectList: resultData || [],
|
|
184
|
-
origDataSource: resultData || []
|
|
185
|
-
});
|
|
123
|
+
setState({ selectList: resultData || [], origDataSource: resultData || [] });
|
|
186
124
|
};
|
|
187
|
-
const successTransformDataHandle = useCallback(res => {
|
|
188
|
-
if (transformResponse && typeof transformResponse ===
|
|
125
|
+
const successTransformDataHandle = useCallback((res) => {
|
|
126
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
189
127
|
return transformResponse(res);
|
|
190
128
|
}
|
|
191
|
-
const {
|
|
192
|
-
status = 200,
|
|
193
|
-
message: msg,
|
|
194
|
-
data
|
|
195
|
-
} = res || {};
|
|
129
|
+
const { status = 200, message: msg, data } = res || {};
|
|
196
130
|
if (status !== 200) {
|
|
197
131
|
message.error(msg);
|
|
198
132
|
return;
|
|
199
133
|
}
|
|
200
134
|
return data;
|
|
201
135
|
}, []);
|
|
202
|
-
|
|
203
|
-
// 配置了异步数据源,拉取枚举数据逻辑 如果有code不掉接口从local里根据code取值
|
|
204
|
-
const fetchFunction = useRequestFunc(useRequest?.service, {
|
|
136
|
+
const fetchFunction = useRequestFunc(useRequest == null ? void 0 : useRequest.service, {
|
|
205
137
|
manual: true,
|
|
206
138
|
debounceWait: 300,
|
|
207
|
-
onSuccess: data => {
|
|
208
|
-
if (transformResponse && typeof transformResponse ===
|
|
139
|
+
onSuccess: (data) => {
|
|
140
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
209
141
|
const responseData = transformResponse(data);
|
|
210
|
-
// 先转换字段名,再处理 code-name 展示与 checkLeaf 标记
|
|
211
142
|
const transformedData = transformFieldNames(responseData);
|
|
212
143
|
const resultData = processData(transformedData);
|
|
213
|
-
setState({
|
|
214
|
-
selectList: countChild(resultData),
|
|
215
|
-
origDataSource: resultData
|
|
216
|
-
});
|
|
144
|
+
setState({ selectList: countChild(resultData), origDataSource: resultData });
|
|
217
145
|
} else {
|
|
218
|
-
defaultOnSuccessFun(
|
|
146
|
+
defaultOnSuccessFun(data);
|
|
219
147
|
}
|
|
220
148
|
},
|
|
221
|
-
...useRequest
|
|
149
|
+
...useRequest == null ? void 0 : useRequest.options
|
|
222
150
|
});
|
|
223
|
-
const cacheList = useRequest
|
|
224
|
-
useImperativeHandle(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
151
|
+
const cacheList = ((_a = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a.cacheKey) ? successTransformDataHandle(fetchFunction == null ? void 0 : fetchFunction.data) : [];
|
|
152
|
+
useImperativeHandle(
|
|
153
|
+
ref,
|
|
154
|
+
() => ({
|
|
155
|
+
useRequestRef: fetchFunction
|
|
156
|
+
})
|
|
157
|
+
);
|
|
229
158
|
useDeepCompareEffect(() => {
|
|
230
|
-
|
|
231
|
-
|
|
159
|
+
var _a2;
|
|
160
|
+
if ((fetchFunction == null ? void 0 : fetchFunction.data) && ((_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.cacheKey)) {
|
|
161
|
+
if (transformResponse && typeof transformResponse === "function") {
|
|
232
162
|
const responseData = transformResponse(fetchFunction.data);
|
|
233
|
-
// 先转换字段名,再处理 code-name 展示与 checkLeaf 标记
|
|
234
163
|
const transformedData = transformFieldNames(responseData);
|
|
235
164
|
const resultData = processData(transformedData);
|
|
236
|
-
setState({
|
|
237
|
-
selectList: countChild(resultData),
|
|
238
|
-
origDataSource: resultData
|
|
239
|
-
});
|
|
165
|
+
setState({ selectList: countChild(resultData), origDataSource: resultData });
|
|
240
166
|
} else {
|
|
241
167
|
defaultOnSuccessFun(fetchFunction.data);
|
|
242
168
|
}
|
|
243
169
|
}
|
|
244
|
-
}, [fetchFunction
|
|
170
|
+
}, [fetchFunction == null ? void 0 : fetchFunction.data, (_b = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _b.cacheKey]);
|
|
245
171
|
useDeepCompareEffect(() => {
|
|
246
172
|
if (enumCode) {
|
|
247
173
|
const dictEnum = dics[enumCode] || [];
|
|
248
|
-
// 先转换字段名,再处理 code-name 展示与 checkLeaf 标记
|
|
249
174
|
const transformedData = transformFieldNames(dictEnum);
|
|
250
175
|
const resultData = processData(transformedData);
|
|
251
176
|
const processedList = countChild(resultData);
|
|
252
|
-
setState({
|
|
253
|
-
selectList: processedList,
|
|
254
|
-
origDataSource: resultData
|
|
255
|
-
});
|
|
177
|
+
setState({ selectList: processedList, origDataSource: resultData });
|
|
256
178
|
} else if (dataSource) {
|
|
257
|
-
// 先转换字段名,再处理 code-name 展示与 checkLeaf 标记
|
|
258
179
|
const transformedData = transformFieldNames(dataSource);
|
|
259
180
|
const resultData = processData(transformedData);
|
|
260
181
|
const processedList = countChild(resultData);
|
|
261
|
-
setState({
|
|
262
|
-
selectList: processedList,
|
|
263
|
-
origDataSource: resultData
|
|
264
|
-
});
|
|
182
|
+
setState({ selectList: processedList, origDataSource: resultData });
|
|
265
183
|
}
|
|
266
184
|
}, [enumCode, dataSource, showCodeName]);
|
|
267
185
|
useDeepCompareEffect(() => {
|
|
268
|
-
// code存在huo dataSource存在,不执行接口请求
|
|
269
186
|
if (enumCode || dataSource) {
|
|
270
|
-
return
|
|
187
|
+
return void 0;
|
|
271
188
|
}
|
|
272
|
-
|
|
273
|
-
const {
|
|
274
|
-
defaultParams,
|
|
275
|
-
manual
|
|
276
|
-
} = useRequest?.options || {};
|
|
277
|
-
// disabled 状态时,不查询接口
|
|
189
|
+
const { defaultParams, manual } = (useRequest == null ? void 0 : useRequest.options) || {};
|
|
278
190
|
if (defaultDisableValue || !useRequest) {
|
|
279
|
-
return
|
|
191
|
+
return void 0;
|
|
280
192
|
}
|
|
281
|
-
if (manual || cacheList
|
|
193
|
+
if (manual || (cacheList == null ? void 0 : cacheList.length)) {
|
|
282
194
|
return;
|
|
283
195
|
}
|
|
284
|
-
const params = Array.isArray(defaultParams) ? defaultParams
|
|
285
|
-
// 执行用户配置的枚举服务,拉取枚举数据进行更新
|
|
196
|
+
const params = Array.isArray(defaultParams) ? defaultParams == null ? void 0 : defaultParams[0] : defaultParams || {};
|
|
286
197
|
fetchFunction.run(params);
|
|
287
|
-
}, [useRequest
|
|
288
|
-
|
|
289
|
-
// disable默认值
|
|
198
|
+
}, [useRequest == null ? void 0 : useRequest.options, defaultDisableValue]);
|
|
290
199
|
if (defaultDisableValue) {
|
|
291
|
-
return
|
|
292
|
-
title: defaultDisableValue,
|
|
293
|
-
children: /*#__PURE__*/_jsx(Input, {
|
|
294
|
-
disabled: true,
|
|
295
|
-
defaultValue: defaultDisableValue,
|
|
296
|
-
style: props?.style
|
|
297
|
-
})
|
|
298
|
-
});
|
|
200
|
+
return /* @__PURE__ */ jsx("span", { title: defaultDisableValue, children: /* @__PURE__ */ jsx(Input, { disabled: true, defaultValue: defaultDisableValue, style: props == null ? void 0 : props.style }) });
|
|
299
201
|
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* 根据值进行回显
|
|
303
|
-
* 注意:此时数据已经是标准格式(label, value, children)
|
|
304
|
-
* @param value 输入值
|
|
305
|
-
* @returns 对应枚举label
|
|
306
|
-
*/
|
|
307
|
-
const transToLabel = value => {
|
|
202
|
+
const transToLabel = (value2) => {
|
|
308
203
|
if (!Array.isArray(origDataSource) || !origDataSource.length) {
|
|
309
204
|
return viewEmpty;
|
|
310
205
|
}
|
|
311
206
|
const labelResult = [];
|
|
312
|
-
const queryLabel = dicts => dicts.map(item => {
|
|
313
|
-
if (
|
|
207
|
+
const queryLabel = (dicts) => dicts.map((item) => {
|
|
208
|
+
if (value2.includes(item.value)) {
|
|
314
209
|
const labelText = item.label;
|
|
315
210
|
labelResult.push(labelText);
|
|
316
211
|
}
|
|
@@ -320,251 +215,182 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
320
215
|
return item;
|
|
321
216
|
});
|
|
322
217
|
queryLabel(origDataSource);
|
|
323
|
-
return labelResult
|
|
218
|
+
return labelResult == null ? void 0 : labelResult.join("、");
|
|
324
219
|
};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
if (valueObj.label) {
|
|
346
|
-
// 处理可能的React元素或带HTML的标签
|
|
347
|
-
if (typeof valueObj.label === 'object' && valueObj.label?.props) {
|
|
348
|
-
const children = valueObj.label?.props?.children;
|
|
349
|
-
if (children?.props?.dangerouslySetInnerHTML?.__html) {
|
|
350
|
-
return children.props.dangerouslySetInnerHTML.__html;
|
|
351
|
-
}
|
|
352
|
-
if (valueObj.label?.props?.dangerouslySetInnerHTML?.__html) {
|
|
353
|
-
return valueObj.label.props.dangerouslySetInnerHTML.__html;
|
|
220
|
+
const maxTagPlaceholder = useCallback(
|
|
221
|
+
(omittedValues) => {
|
|
222
|
+
const flatData = getFlatTreeData(selectList, finalFieldNames);
|
|
223
|
+
const omittedLabels = omittedValues.map((valueObj) => {
|
|
224
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h;
|
|
225
|
+
const targetValue = valueObj.value || valueObj[finalFieldNames.value];
|
|
226
|
+
const matchedItem = flatData.find((item) => item[finalFieldNames.value] === targetValue);
|
|
227
|
+
if (matchedItem) {
|
|
228
|
+
return showCodeName ? `${matchedItem[finalFieldNames.value]}-${matchedItem[finalFieldNames.label]}` : matchedItem[finalFieldNames.label];
|
|
229
|
+
}
|
|
230
|
+
if (valueObj.label) {
|
|
231
|
+
if (typeof valueObj.label === "object" && ((_a2 = valueObj.label) == null ? void 0 : _a2.props)) {
|
|
232
|
+
const children = (_c2 = (_b2 = valueObj.label) == null ? void 0 : _b2.props) == null ? void 0 : _c2.children;
|
|
233
|
+
if ((_e2 = (_d2 = children == null ? void 0 : children.props) == null ? void 0 : _d2.dangerouslySetInnerHTML) == null ? void 0 : _e2.__html) {
|
|
234
|
+
return children.props.dangerouslySetInnerHTML.__html;
|
|
235
|
+
}
|
|
236
|
+
if ((_h = (_g = (_f2 = valueObj.label) == null ? void 0 : _f2.props) == null ? void 0 : _g.dangerouslySetInnerHTML) == null ? void 0 : _h.__html) {
|
|
237
|
+
return valueObj.label.props.dangerouslySetInnerHTML.__html;
|
|
238
|
+
}
|
|
239
|
+
return children || valueObj.label;
|
|
354
240
|
}
|
|
355
|
-
|
|
356
|
-
return children || valueObj.label;
|
|
241
|
+
return valueObj.label;
|
|
357
242
|
}
|
|
358
|
-
return
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
children: ["+ ", /*#__PURE__*/_jsx("b", {
|
|
370
|
-
className: "pro-tree-more-count",
|
|
371
|
-
children: omittedValues.length
|
|
372
|
-
}), "..."]
|
|
373
|
-
})
|
|
374
|
-
});
|
|
375
|
-
}, [selectList, finalFieldNames, showCodeName]);
|
|
376
|
-
|
|
377
|
-
// 纯展示处理
|
|
243
|
+
return targetValue;
|
|
244
|
+
});
|
|
245
|
+
const tooltipContent = omittedLabels.join("、");
|
|
246
|
+
return /* @__PURE__ */ jsx(Tooltip, { title: tooltipContent, placement: "topLeft", children: /* @__PURE__ */ jsxs("span", { children: [
|
|
247
|
+
"+ ",
|
|
248
|
+
/* @__PURE__ */ jsx("b", { className: "pro-tree-more-count", children: omittedValues.length }),
|
|
249
|
+
"..."
|
|
250
|
+
] }) });
|
|
251
|
+
},
|
|
252
|
+
[selectList, finalFieldNames, showCodeName]
|
|
253
|
+
);
|
|
378
254
|
if (isView || props.isView) {
|
|
379
255
|
if (Array.isArray(value)) {
|
|
380
|
-
// 从selectProps或props中获取maxTagCount,因为此时treeProps还未定义
|
|
381
256
|
const maxTagCount = selectProps.maxTagCount || props.maxTagCount;
|
|
382
|
-
|
|
383
|
-
const shouldTruncate = typeof maxTagCount === 'number' && value.length > maxTagCount;
|
|
257
|
+
const shouldTruncate = typeof maxTagCount === "number" && value.length > maxTagCount;
|
|
384
258
|
if (shouldTruncate) {
|
|
385
|
-
|
|
386
|
-
const maxCount = typeof maxTagCount === 'number' ? maxTagCount : 0;
|
|
259
|
+
const maxCount = typeof maxTagCount === "number" ? maxTagCount : 0;
|
|
387
260
|
const visibleItems = value.slice(0, maxCount);
|
|
388
261
|
const hiddenItems = value.slice(maxCount);
|
|
389
262
|
const hiddenCount = value.length - maxCount;
|
|
390
263
|
const visibleText = transToLabel(visibleItems);
|
|
391
|
-
const hiddenText = transToLabel(hiddenItems);
|
|
392
|
-
const moreText = locale
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
children: [visibleText, "\u3001", /*#__PURE__*/_jsx(Tooltip, {
|
|
406
|
-
title: hiddenText,
|
|
407
|
-
placement: "topLeft",
|
|
408
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
409
|
-
children: moreText
|
|
410
|
-
})
|
|
411
|
-
})]
|
|
412
|
-
});
|
|
264
|
+
const hiddenText = transToLabel(hiddenItems);
|
|
265
|
+
const moreText = ((_d = (_c = locale) == null ? void 0 : _c.ProForm) == null ? void 0 : _d.moreItems) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
266
|
+
locale.ProForm.moreItems.split("{count}")[0],
|
|
267
|
+
/* @__PURE__ */ jsx("b", { className: "pro-tree-more-count", children: hiddenCount }),
|
|
268
|
+
locale.ProForm.moreItems.split("{count}")[1]
|
|
269
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
270
|
+
/* @__PURE__ */ jsx("b", { className: "pro-tree-more-count", children: hiddenCount }),
|
|
271
|
+
" more..."
|
|
272
|
+
] });
|
|
273
|
+
return /* @__PURE__ */ jsxs(Container, { viewEmpty, children: [
|
|
274
|
+
visibleText,
|
|
275
|
+
"、",
|
|
276
|
+
/* @__PURE__ */ jsx(Tooltip, { title: hiddenText, placement: "topLeft", children: /* @__PURE__ */ jsx("span", { children: moreText }) })
|
|
277
|
+
] });
|
|
413
278
|
}
|
|
414
|
-
|
|
415
|
-
// 不需要截断,正常显示
|
|
416
|
-
return /*#__PURE__*/_jsx(Container, {
|
|
417
|
-
tooltip: true,
|
|
418
|
-
viewEmpty: viewEmpty,
|
|
419
|
-
children: transToLabel(value)
|
|
420
|
-
});
|
|
279
|
+
return /* @__PURE__ */ jsx(Container, { tooltip: true, viewEmpty, children: transToLabel(value) });
|
|
421
280
|
}
|
|
422
|
-
return
|
|
423
|
-
viewEmpty: viewEmpty,
|
|
424
|
-
children: value ? transToLabel([value]) : null
|
|
425
|
-
});
|
|
281
|
+
return /* @__PURE__ */ jsx(Container, { viewEmpty, children: value ? transToLabel([value]) : null });
|
|
426
282
|
}
|
|
427
283
|
const Icon = () => {
|
|
428
|
-
return
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
284
|
+
return /* @__PURE__ */ jsx(
|
|
285
|
+
"svg",
|
|
286
|
+
{
|
|
287
|
+
className: "icon",
|
|
288
|
+
viewBox: "0 0 1433 1024",
|
|
289
|
+
version: "1.1",
|
|
290
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
291
|
+
"p-id": "2318",
|
|
292
|
+
width: "1em",
|
|
293
|
+
height: "1em",
|
|
294
|
+
children: /* @__PURE__ */ jsx(
|
|
295
|
+
"path",
|
|
296
|
+
{
|
|
297
|
+
d: "M209.92 337.2032l362.0864 361.984L1223.68 47.5136l144.7936 144.896-796.4672 796.4672-506.88-506.88z",
|
|
298
|
+
"p-id": "2319",
|
|
299
|
+
fill: "currentColor"
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
);
|
|
442
304
|
};
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (!text || !text.includes('highlight-search-text')) return text;
|
|
305
|
+
const renderHighlightLabel = (text) => {
|
|
306
|
+
if (!text || !text.includes("highlight-search-text"))
|
|
307
|
+
return text;
|
|
447
308
|
const parts = text.split(/(<span class="highlight-search-text">.*?<\/span>)/g);
|
|
448
309
|
return parts.map((part, i) => {
|
|
449
310
|
const match = part.match(/^<span class="highlight-search-text">(.*?)<\/span>$/);
|
|
450
311
|
if (match) {
|
|
451
|
-
return
|
|
452
|
-
className: "highlight-search-text",
|
|
453
|
-
children: match[1]
|
|
454
|
-
}, i);
|
|
312
|
+
return /* @__PURE__ */ jsx("span", { className: "highlight-search-text", children: match[1] }, i);
|
|
455
313
|
}
|
|
456
314
|
return part;
|
|
457
315
|
});
|
|
458
316
|
};
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* 自定义渲染子树
|
|
462
|
-
* 注意:此时数据已经是标准格式(label, value, children)
|
|
463
|
-
* @param node 每个节点数据对象(标准格式)
|
|
464
|
-
* @returns 整个react节点树
|
|
465
|
-
*/
|
|
466
317
|
const renderTreeNode = (node, grade) => {
|
|
467
|
-
const {
|
|
468
|
-
children,
|
|
469
|
-
icon,
|
|
470
|
-
label,
|
|
471
|
-
value: nodeValue,
|
|
472
|
-
key: nodeKey
|
|
473
|
-
} = node;
|
|
318
|
+
const { children, icon, label, value: nodeValue, key: nodeKey } = node;
|
|
474
319
|
let labelText = label;
|
|
475
|
-
let
|
|
476
|
-
let key = nodeValue;
|
|
477
|
-
if (nodeKey !==
|
|
320
|
+
let value2 = nodeValue;
|
|
321
|
+
let key = nodeValue;
|
|
322
|
+
if (nodeKey !== void 0) {
|
|
478
323
|
key = nodeKey;
|
|
479
324
|
}
|
|
480
|
-
|
|
481
|
-
if (['undefined-undefined', 'undefined'].includes(labelText) && !value && !key) {
|
|
325
|
+
if (["undefined-undefined", "undefined"].includes(labelText) && !value2 && !key) {
|
|
482
326
|
if (showCodeName) {
|
|
483
|
-
labelText = `${node
|
|
327
|
+
labelText = `${node == null ? void 0 : node.value}-${node == null ? void 0 : node.label}`;
|
|
484
328
|
} else {
|
|
485
|
-
labelText = node
|
|
329
|
+
labelText = node == null ? void 0 : node.label;
|
|
486
330
|
}
|
|
487
|
-
|
|
488
|
-
key = node
|
|
331
|
+
value2 = node == null ? void 0 : node.value;
|
|
332
|
+
key = node == null ? void 0 : node.value;
|
|
489
333
|
}
|
|
490
|
-
const titleHtml =
|
|
491
|
-
|
|
492
|
-
});
|
|
493
|
-
let searchKey = '';
|
|
334
|
+
const titleHtml = /* @__PURE__ */ jsx("span", { children: renderHighlightLabel(labelText) });
|
|
335
|
+
let searchKey = "";
|
|
494
336
|
if (showCodeName) {
|
|
495
|
-
searchKey = `${
|
|
337
|
+
searchKey = `${value2}-${labelText}`;
|
|
496
338
|
} else {
|
|
497
339
|
searchKey = labelText;
|
|
498
340
|
}
|
|
499
|
-
let title = treeCheckable ? titleHtml :
|
|
500
|
-
className: "check-option-text",
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
children: titleHtml
|
|
504
|
-
}), !disabled ? /*#__PURE__*/_jsx("span", {
|
|
505
|
-
className: "check-mark-icon",
|
|
506
|
-
children: /*#__PURE__*/_jsx(Icon, {})
|
|
507
|
-
}) : null]
|
|
508
|
-
});
|
|
341
|
+
let title = treeCheckable ? titleHtml : /* @__PURE__ */ jsxs("span", { className: "check-option-text", children: [
|
|
342
|
+
/* @__PURE__ */ jsx("span", { className: "check-option-text-content", children: titleHtml }),
|
|
343
|
+
!disabled ? /* @__PURE__ */ jsx("span", { className: "check-mark-icon", children: /* @__PURE__ */ jsx(Icon, {}) }) : null
|
|
344
|
+
] });
|
|
509
345
|
if (_showEllipse) {
|
|
510
|
-
title =
|
|
511
|
-
children: treeCheckable ? titleHtml : /*#__PURE__*/_jsx("span", {
|
|
512
|
-
className: "check-option-text",
|
|
513
|
-
children: /*#__PURE__*/_jsx("span", {
|
|
514
|
-
className: "check-option-text-content",
|
|
515
|
-
children: titleHtml
|
|
516
|
-
})
|
|
517
|
-
})
|
|
518
|
-
});
|
|
346
|
+
title = /* @__PURE__ */ jsx(AdaptiveTooltip, { children: treeCheckable ? titleHtml : /* @__PURE__ */ jsx("span", { className: "check-option-text", children: /* @__PURE__ */ jsx("span", { className: "check-option-text-content", children: titleHtml }) }) });
|
|
519
347
|
}
|
|
520
348
|
if (!children) {
|
|
521
|
-
return
|
|
522
|
-
|
|
523
|
-
|
|
349
|
+
return /* @__PURE__ */ jsx(
|
|
350
|
+
TreeSelect.TreeNode,
|
|
351
|
+
{
|
|
352
|
+
value: value2,
|
|
353
|
+
title,
|
|
354
|
+
label: searchKey,
|
|
355
|
+
disabled: node.disabled,
|
|
356
|
+
checkable: node.checkable,
|
|
357
|
+
icon,
|
|
358
|
+
className: `node-val-${value2}`
|
|
359
|
+
},
|
|
360
|
+
key
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
const sonGrade = grade + 1;
|
|
364
|
+
return /* @__PURE__ */ jsx(
|
|
365
|
+
TreeSelect.TreeNode,
|
|
366
|
+
{
|
|
367
|
+
value: value2,
|
|
368
|
+
title,
|
|
524
369
|
label: searchKey,
|
|
525
370
|
disabled: node.disabled,
|
|
526
371
|
checkable: node.checkable,
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
},
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
return /*#__PURE__*/_jsx(TreeSelect.TreeNode, {
|
|
533
|
-
value: value,
|
|
534
|
-
title: title,
|
|
535
|
-
label: searchKey,
|
|
536
|
-
disabled: node.disabled,
|
|
537
|
-
checkable: node.checkable,
|
|
538
|
-
className: `node-val-${value}`,
|
|
539
|
-
children: children.map(child => renderTreeNode(child, sonGrade))
|
|
540
|
-
}, key);
|
|
372
|
+
className: `node-val-${value2}`,
|
|
373
|
+
children: children.map((child) => renderTreeNode(child, sonGrade))
|
|
374
|
+
},
|
|
375
|
+
key
|
|
376
|
+
);
|
|
541
377
|
};
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* 从树形数据中找出用户搜索得数据,并且将搜索字符串高亮标识
|
|
545
|
-
* 注意:此时数据已经是标准格式(label, value, children)
|
|
546
|
-
* @param data 全量树(标准格式)
|
|
547
|
-
* @param searchStr 搜索字符串
|
|
548
|
-
* @returns 处理后得树
|
|
549
|
-
*/
|
|
550
378
|
function filterTree(sourceList, keyWord) {
|
|
551
|
-
const filterData = function
|
|
552
|
-
const currentAllNodeChild = [];
|
|
553
|
-
// 遍历数组
|
|
379
|
+
const filterData = function(data) {
|
|
380
|
+
const currentAllNodeChild = [];
|
|
554
381
|
for (let i = 0; i < data.length; i++) {
|
|
555
382
|
const item = data[i];
|
|
556
|
-
|
|
557
|
-
let currentNodeChild = []; // 记录当前节点下得子节点匹配到的节点个数
|
|
383
|
+
let currentNodeChild = [];
|
|
558
384
|
if (item.children && item.children.length > 0) {
|
|
559
385
|
currentNodeChild = filterData(item.children);
|
|
560
386
|
}
|
|
561
|
-
// 迭代完子节点向上回溯,如果有匹配到得子节点,那么加入当前节点得孩子对象上,否则加入得是空数组
|
|
562
387
|
item.children = currentNodeChild;
|
|
563
|
-
|
|
564
|
-
// @ts-ignore
|
|
565
|
-
if (item.label && item.label.indexOf(keyWord) > -1 && selectProps?.mode !== 'treeSelect') {
|
|
388
|
+
if (item.label && item.label.indexOf(keyWord) > -1 && (selectProps == null ? void 0 : selectProps.mode) !== "treeSelect") {
|
|
566
389
|
const regExp = new RegExp(keyWord);
|
|
567
|
-
item.label = item.label.replace(
|
|
390
|
+
item.label = item.label.replace(
|
|
391
|
+
regExp,
|
|
392
|
+
`<span class="highlight-search-text">${keyWord}</span>`
|
|
393
|
+
);
|
|
568
394
|
}
|
|
569
395
|
currentAllNodeChild.push(item);
|
|
570
396
|
}
|
|
@@ -573,40 +399,24 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
573
399
|
sourceList = filterData(sourceList);
|
|
574
400
|
return sourceList;
|
|
575
401
|
}
|
|
576
|
-
const searchTreeEvent =
|
|
402
|
+
const searchTreeEvent = debounce(async (searchVal) => {
|
|
577
403
|
if (!searchVal) {
|
|
578
|
-
setState({
|
|
579
|
-
selectList: _cloneDeep(origDataSource || [])
|
|
580
|
-
});
|
|
404
|
+
setState({ selectList: cloneDeep(origDataSource || []) });
|
|
581
405
|
return null;
|
|
582
406
|
}
|
|
583
|
-
const result = filterTree(
|
|
584
|
-
setState({
|
|
585
|
-
selectList: result || []
|
|
586
|
-
});
|
|
407
|
+
const result = filterTree(cloneDeep(origDataSource || []), searchVal);
|
|
408
|
+
setState({ selectList: result || [] });
|
|
587
409
|
}, 500);
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* 从树形数据中查找节点
|
|
591
|
-
* 注意:此时数据已经是标准格式(label, value, children)
|
|
592
|
-
* @param treeList 树形数据(标准格式)
|
|
593
|
-
* @param nodeValue 节点值
|
|
594
|
-
* @returns 找到的节点
|
|
595
|
-
*/
|
|
596
410
|
function findTreeNode(treeList, nodeValue) {
|
|
597
411
|
let result = {};
|
|
598
|
-
const filterData = function
|
|
412
|
+
const filterData = function(data) {
|
|
599
413
|
for (let i = 0; i < data.length; i++) {
|
|
600
414
|
const item = data[i];
|
|
601
415
|
if (item.value === nodeValue || Array.isArray(nodeValue) && nodeValue.includes(item.value)) {
|
|
602
|
-
result = {
|
|
603
|
-
...item
|
|
604
|
-
};
|
|
605
|
-
// 删除 children 字段,避免循环引用
|
|
416
|
+
result = { ...item };
|
|
606
417
|
delete result.children;
|
|
607
418
|
return null;
|
|
608
419
|
}
|
|
609
|
-
// 一直递归到最后一层子节点
|
|
610
420
|
if (item.children && item.children.length > 0) {
|
|
611
421
|
filterData(item.children);
|
|
612
422
|
}
|
|
@@ -615,20 +425,13 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
615
425
|
filterData(treeList);
|
|
616
426
|
return result;
|
|
617
427
|
}
|
|
618
|
-
/**
|
|
619
|
-
* 根据值获取标签
|
|
620
|
-
* 注意:此时数据已经是标准格式(label, value, children)
|
|
621
|
-
* @param treeList 树形数据(标准格式)
|
|
622
|
-
* @param nodeValue 节点值
|
|
623
|
-
* @returns 标签对象或数组
|
|
624
|
-
*/
|
|
625
428
|
function getLabelByValue(treeList, nodeValue) {
|
|
626
429
|
let result = nodeValue;
|
|
627
430
|
if (nodeValue) {
|
|
628
431
|
if (Array.isArray(nodeValue)) {
|
|
629
432
|
result = [];
|
|
630
|
-
nodeValue.map(item => {
|
|
631
|
-
const res = findTreeNode(treeList, item
|
|
433
|
+
nodeValue.map((item) => {
|
|
434
|
+
const res = findTreeNode(treeList, item == null ? void 0 : item.value);
|
|
632
435
|
res && result.push(res);
|
|
633
436
|
return item;
|
|
634
437
|
});
|
|
@@ -639,13 +442,11 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
639
442
|
return result;
|
|
640
443
|
}
|
|
641
444
|
const handleChange = (newVal, label, extra) => {
|
|
642
|
-
|
|
643
|
-
// 注意:此时数据已经是标准格式(label, value, children)
|
|
644
|
-
const _selectList = selectList.map(item => {
|
|
445
|
+
const _selectList = selectList.map((item) => {
|
|
645
446
|
let _label = item.label;
|
|
646
447
|
if (_label) {
|
|
647
448
|
const regex = /<span class="highlight-search-text">(.*?)<\/span>/g;
|
|
648
|
-
_label = item.label = _label.replace(regex,
|
|
449
|
+
_label = item.label = _label.replace(regex, "$1");
|
|
649
450
|
}
|
|
650
451
|
return {
|
|
651
452
|
...item,
|
|
@@ -653,65 +454,60 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
653
454
|
};
|
|
654
455
|
});
|
|
655
456
|
let result = newVal;
|
|
656
|
-
if (props
|
|
457
|
+
if (props == null ? void 0 : props.labelInValue) {
|
|
657
458
|
result = getLabelByValue(_selectList, newVal);
|
|
658
459
|
}
|
|
659
|
-
|
|
660
|
-
|
|
460
|
+
const options = restoreCodeNameLabel(
|
|
461
|
+
findTreeNode(_selectList, extra == null ? void 0 : extra.triggerValue),
|
|
462
|
+
showCodeName
|
|
463
|
+
);
|
|
661
464
|
onChange && onChange(result, options, extra);
|
|
662
|
-
|
|
663
|
-
showSearch && searchTreeEvent('');
|
|
465
|
+
showSearch && searchTreeEvent("");
|
|
664
466
|
};
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* 全局点击事件, 如果是单选的情况那么点击选中节点后取消勾选
|
|
668
|
-
* @param e 事件源
|
|
669
|
-
*/
|
|
670
|
-
const nodeChangeEvent = e => {
|
|
467
|
+
const nodeChangeEvent = (e) => {
|
|
671
468
|
const el = e.target;
|
|
672
469
|
const classStr = el.className;
|
|
673
|
-
if (classStr && !treeCheckable && typeof classStr ===
|
|
674
|
-
const [valStr] = classStr.split(
|
|
675
|
-
if (valStr && classStr.startsWith(
|
|
676
|
-
const choiceVal = valStr.replace(
|
|
470
|
+
if (classStr && !treeCheckable && typeof classStr === "string") {
|
|
471
|
+
const [valStr] = classStr.split(" ");
|
|
472
|
+
if (valStr && classStr.startsWith("node-val-")) {
|
|
473
|
+
const choiceVal = valStr.replace("node-val-", "");
|
|
677
474
|
if (value === choiceVal) {
|
|
678
|
-
onChange && onChange(
|
|
475
|
+
onChange && onChange(void 0, [], null);
|
|
679
476
|
}
|
|
680
477
|
}
|
|
681
478
|
}
|
|
682
479
|
};
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
let tenCountClass = '';
|
|
686
|
-
const countTen = enums => {
|
|
480
|
+
let tenCountClass = "";
|
|
481
|
+
const countTen = (enums) => {
|
|
687
482
|
if (!enums) {
|
|
688
|
-
return
|
|
483
|
+
return "";
|
|
689
484
|
}
|
|
690
485
|
let noneChild = true;
|
|
691
|
-
const loopCount = data => {
|
|
692
|
-
data.map(item => {
|
|
693
|
-
|
|
486
|
+
const loopCount = (data) => {
|
|
487
|
+
data.map((item) => {
|
|
488
|
+
var _a2;
|
|
489
|
+
if ((_a2 = item == null ? void 0 : item.children) == null ? void 0 : _a2.length) {
|
|
694
490
|
noneChild = false;
|
|
695
491
|
}
|
|
696
492
|
return item;
|
|
697
493
|
});
|
|
698
494
|
};
|
|
699
495
|
loopCount(enums);
|
|
700
|
-
return noneChild ?
|
|
496
|
+
return noneChild ? "ten-count-tree-node" : "";
|
|
701
497
|
};
|
|
702
498
|
tenCountClass = countTen(selectList);
|
|
703
499
|
const cls = classnames({
|
|
704
|
-
|
|
500
|
+
"pro-tree-select": true,
|
|
705
501
|
[`${className}`]: className
|
|
706
502
|
});
|
|
707
|
-
const innerClass = treeCheckable ?
|
|
503
|
+
const innerClass = treeCheckable ? "checkable-tree pro" : `${tenCountClass} signal-tree`;
|
|
708
504
|
const dropDownClassName = classnames({
|
|
709
|
-
|
|
505
|
+
"pro-tree-select-drop-down-container": true,
|
|
710
506
|
[`${innerClass}`]: true,
|
|
711
507
|
[`${popupClassName}`]: popupClassName
|
|
712
508
|
});
|
|
713
|
-
const selectClassNames = selectProps
|
|
714
|
-
const selectStyles = selectProps
|
|
509
|
+
const selectClassNames = selectProps == null ? void 0 : selectProps.classNames;
|
|
510
|
+
const selectStyles = selectProps == null ? void 0 : selectProps.styles;
|
|
715
511
|
const treeProps = {
|
|
716
512
|
disabled,
|
|
717
513
|
showSearch,
|
|
@@ -726,10 +522,7 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
726
522
|
value,
|
|
727
523
|
onChange: handleChange,
|
|
728
524
|
listHeight: listHeight || 320,
|
|
729
|
-
style: {
|
|
730
|
-
width: width || '100%',
|
|
731
|
-
...style
|
|
732
|
-
},
|
|
525
|
+
style: { width: width || "100%", ...style },
|
|
733
526
|
onSearch: searchTreeEvent,
|
|
734
527
|
allowClear: allowClear || true,
|
|
735
528
|
treeNodeFilterProp,
|
|
@@ -740,20 +533,20 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
740
533
|
classNames: {
|
|
741
534
|
...selectClassNames,
|
|
742
535
|
popup: {
|
|
743
|
-
...selectClassNames
|
|
744
|
-
root: [selectClassNames
|
|
536
|
+
...selectClassNames == null ? void 0 : selectClassNames.popup,
|
|
537
|
+
root: [(_e = selectClassNames == null ? void 0 : selectClassNames.popup) == null ? void 0 : _e.root, dropDownClassName].filter(Boolean).join(" ")
|
|
745
538
|
}
|
|
746
539
|
},
|
|
747
540
|
styles: {
|
|
748
541
|
...selectStyles,
|
|
749
542
|
popup: {
|
|
750
|
-
...selectStyles
|
|
543
|
+
...selectStyles == null ? void 0 : selectStyles.popup,
|
|
751
544
|
root: {
|
|
752
545
|
maxHeight: 320,
|
|
753
|
-
paddingTop:
|
|
754
|
-
maxWidth:
|
|
546
|
+
paddingTop: "0px",
|
|
547
|
+
maxWidth: "580px",
|
|
755
548
|
...dropdownStyle,
|
|
756
|
-
...selectStyles
|
|
549
|
+
...(_f = selectStyles == null ? void 0 : selectStyles.popup) == null ? void 0 : _f.root
|
|
757
550
|
}
|
|
758
551
|
}
|
|
759
552
|
}
|
|
@@ -761,15 +554,18 @@ export const ProTreeSelect = (props, ref) => {
|
|
|
761
554
|
if (value === null) {
|
|
762
555
|
delete treeProps.value;
|
|
763
556
|
}
|
|
764
|
-
return
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
children: /*#__PURE__*/_jsx(TreeSelect, {
|
|
557
|
+
return /* @__PURE__ */ jsx("div", { onClick: nodeChangeEvent, className: cls, children: /* @__PURE__ */ jsx(
|
|
558
|
+
TreeSelect,
|
|
559
|
+
{
|
|
768
560
|
placeholder: placeholder || locale.ProForm.treeSelectPlaceholder,
|
|
769
|
-
maxTagPlaceholder
|
|
561
|
+
maxTagPlaceholder,
|
|
770
562
|
...treeProps,
|
|
771
|
-
children: selectList.map(node => renderTreeNode(node, 1))
|
|
772
|
-
}
|
|
773
|
-
});
|
|
563
|
+
children: selectList.map((node) => renderTreeNode(node, 1))
|
|
564
|
+
}
|
|
565
|
+
) });
|
|
566
|
+
};
|
|
567
|
+
var ProTreeSelect_default = forwardRef(ProTreeSelect);
|
|
568
|
+
export {
|
|
569
|
+
ProTreeSelect,
|
|
570
|
+
ProTreeSelect_default as default
|
|
774
571
|
};
|
|
775
|
-
export default /*#__PURE__*/forwardRef(ProTreeSelect);
|