@zat-design/sisyphus-react 4.5.10-beta.1 → 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.
Files changed (266) hide show
  1. package/es/FormsProvider/index.js +14 -21
  2. package/es/ProAction/components/CheckModalContent/index.js +12 -26
  3. package/es/ProAction/index.js +79 -83
  4. package/es/ProAction/propsType.js +0 -1
  5. package/es/ProConfigProvider/index.js +63 -110
  6. package/es/ProConfigProvider/propsType.js +0 -1
  7. package/es/ProDownload/index.js +55 -65
  8. package/es/ProDownload/propsType.js +0 -1
  9. package/es/ProDownload/utils.js +61 -95
  10. package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
  11. package/es/ProDrawerForm/components/ProModal/index.js +77 -108
  12. package/es/ProDrawerForm/components/index.js +6 -2
  13. package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
  14. package/es/ProDrawerForm/index.js +29 -38
  15. package/es/ProDrawerForm/propsType.js +0 -1
  16. package/es/ProDrawerForm/utils/index.js +18 -36
  17. package/es/ProEditLabel/components/RenderProForm.js +45 -49
  18. package/es/ProEditLabel/index.js +126 -163
  19. package/es/ProEditLabel/propsType.js +0 -1
  20. package/es/ProEditLabel/utils/index.js +5 -8
  21. package/es/ProEditTable/components/ActionButton/index.js +111 -119
  22. package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
  23. package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
  24. package/es/ProEditTable/components/RcTable/index.js +6 -4
  25. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
  26. package/es/ProEditTable/components/RenderField/index.js +490 -587
  27. package/es/ProEditTable/components/RenderField/propsType.js +0 -1
  28. package/es/ProEditTable/components/RenderField/tools.js +115 -112
  29. package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
  30. package/es/ProEditTable/components/Summary/index.js +38 -64
  31. package/es/ProEditTable/components/Validator/index.js +46 -46
  32. package/es/ProEditTable/components/index.js +12 -5
  33. package/es/ProEditTable/index.js +456 -378
  34. package/es/ProEditTable/propsType.js +0 -1
  35. package/es/ProEditTable/utils/config.js +60 -122
  36. package/es/ProEditTable/utils/diffOriginal.js +45 -82
  37. package/es/ProEditTable/utils/getDefaultProps.js +19 -24
  38. package/es/ProEditTable/utils/index.js +150 -236
  39. package/es/ProEditTable/utils/tools.js +149 -286
  40. package/es/ProEditTable/utils/transform.js +25 -30
  41. package/es/ProEditTable/utils/useEditTableError.js +30 -43
  42. package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
  43. package/es/ProEditTable/utils/validateAll.js +87 -154
  44. package/es/ProEnum/components/Group.js +38 -30
  45. package/es/ProEnum/components/Tag.js +22 -26
  46. package/es/ProEnum/hooks/useEnum.js +48 -116
  47. package/es/ProEnum/hooks/useEnumRequest.js +128 -179
  48. package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
  49. package/es/ProEnum/index.js +162 -172
  50. package/es/ProEnum/propsType.js +0 -1
  51. package/es/ProEnum/utils/eventCenter.js +10 -12
  52. package/es/ProEnum/utils/frequentEnum.js +35 -92
  53. package/es/ProEnum/utils/getEnum.js +32 -90
  54. package/es/ProEnum/utils/getEnumLabel.js +44 -49
  55. package/es/ProEnum/utils/index.js +93 -207
  56. package/es/ProForm/components/Container.js +13 -28
  57. package/es/ProForm/components/FormFooter/index.js +36 -44
  58. package/es/ProForm/components/FormFooter/propsType.js +0 -1
  59. package/es/ProForm/components/base/Checkbox/index.js +32 -59
  60. package/es/ProForm/components/base/DatePicker/index.js +49 -71
  61. package/es/ProForm/components/base/Input/index.js +63 -97
  62. package/es/ProForm/components/base/Input/propsType.js +0 -1
  63. package/es/ProForm/components/base/InputNumber/index.js +118 -172
  64. package/es/ProForm/components/base/Radio/index.js +39 -52
  65. package/es/ProForm/components/base/RangePicker/index.js +109 -127
  66. package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
  67. package/es/ProForm/components/base/Select/index.js +63 -89
  68. package/es/ProForm/components/base/Switch/index.js +27 -35
  69. package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
  70. package/es/ProForm/components/base/TextArea/index.js +30 -41
  71. package/es/ProForm/components/base/TimePicker/index.js +27 -37
  72. package/es/ProForm/components/combination/Container/index.js +37 -47
  73. package/es/ProForm/components/combination/Container/propsType.js +0 -1
  74. package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
  75. package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -103
  76. package/es/ProForm/components/combination/FormList/components/Empty.js +27 -54
  77. package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
  78. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
  79. package/es/ProForm/components/combination/FormList/index.js +151 -161
  80. package/es/ProForm/components/combination/FormList/propsType.js +0 -1
  81. package/es/ProForm/components/combination/FormList/utils.js +22 -38
  82. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
  83. package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
  84. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +105 -206
  85. package/es/ProForm/components/combination/Group/hooks/index.js +68 -128
  86. package/es/ProForm/components/combination/Group/index.js +87 -126
  87. package/es/ProForm/components/combination/Group/propsType.js +0 -1
  88. package/es/ProForm/components/combination/Group/utils/index.js +124 -239
  89. package/es/ProForm/components/combination/ProCascader/index.js +156 -199
  90. package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
  91. package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
  92. package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +63 -75
  93. package/es/ProForm/components/combination/ProModalSelect/index.js +290 -348
  94. package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
  95. package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
  96. package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
  97. package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
  98. package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
  99. package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
  100. package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
  101. package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
  102. package/es/ProForm/components/index.js +56 -34
  103. package/es/ProForm/components/render/ChangedWrapper.js +85 -94
  104. package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
  105. package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
  106. package/es/ProForm/components/render/Render.js +223 -329
  107. package/es/ProForm/components/render/RenderFields.js +76 -113
  108. package/es/ProForm/components/render/propsType.js +0 -1
  109. package/es/ProForm/hooks/useControlled.js +8 -10
  110. package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
  111. package/es/ProForm/hooks/useFieldProps.js +8 -4
  112. package/es/ProForm/hooks/useForm.js +50 -110
  113. package/es/ProForm/hooks/useRules.js +17 -33
  114. package/es/ProForm/hooks/useShouldUpdate.js +77 -152
  115. package/es/ProForm/hooks/useWatch.js +58 -129
  116. package/es/ProForm/index.js +157 -194
  117. package/es/ProForm/propsType.js +15 -7
  118. package/es/ProForm/utils/buildFormItemProps.js +51 -58
  119. package/es/ProForm/utils/diffOriginal.js +43 -73
  120. package/es/ProForm/utils/getDefaultProps.js +18 -24
  121. package/es/ProForm/utils/index.js +159 -234
  122. package/es/ProForm/utils/processDependencies.js +21 -60
  123. package/es/ProForm/utils/reactiveValues.js +20 -34
  124. package/es/ProForm/utils/rulesCreator.js +42 -40
  125. package/es/ProForm/utils/transformNames.js +10 -13
  126. package/es/ProForm/utils/transformValue.js +16 -29
  127. package/es/ProForm/utils/valueType.js +96 -178
  128. package/es/ProIcon/config/index.js +340 -274
  129. package/es/ProIcon/index.js +135 -209
  130. package/es/ProIcon/propsTypes.js +0 -1
  131. package/es/ProIcon/utils/index.js +24 -39
  132. package/es/ProLayout/components/Layout/Header/index.js +108 -141
  133. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
  134. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +111 -137
  135. package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
  136. package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
  137. package/es/ProLayout/components/Layout/Menu/index.js +92 -89
  138. package/es/ProLayout/components/Layout/Notice/index.js +13 -27
  139. package/es/ProLayout/components/Layout/index.js +8 -3
  140. package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
  141. package/es/ProLayout/components/ProCollapse/index.js +89 -111
  142. package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
  143. package/es/ProLayout/components/ProFooter/index.js +27 -25
  144. package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
  145. package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
  146. package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -86
  147. package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
  148. package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
  149. package/es/ProLayout/components/ProHeader/components/index.js +6 -2
  150. package/es/ProLayout/components/ProHeader/index.js +216 -356
  151. package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
  152. package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
  153. package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -64
  154. package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
  155. package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
  156. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
  157. package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
  158. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
  159. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
  160. package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +290 -408
  161. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +132 -95
  162. package/es/ProLayout/components/TabsManager/index.js +406 -390
  163. package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
  164. package/es/ProLayout/components/TabsManager/utils/historyObserver.js +26 -23
  165. package/es/ProLayout/components/TabsManager/utils/index.js +127 -184
  166. package/es/ProLayout/components/index.js +8 -3
  167. package/es/ProLayout/index.js +171 -229
  168. package/es/ProLayout/propTypes.js +12 -52
  169. package/es/ProLayout/utils/index.js +48 -128
  170. package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
  171. package/es/ProSelect/index.js +184 -229
  172. package/es/ProSelect/propsType.js +0 -1
  173. package/es/ProSelect/utils/index.js +100 -146
  174. package/es/ProStep/components/Anchor/index.js +71 -82
  175. package/es/ProStep/components/Item/index.js +49 -56
  176. package/es/ProStep/components/LazyLoad/index.js +23 -29
  177. package/es/ProStep/components/Listener/index.js +20 -33
  178. package/es/ProStep/components/Step/index.js +31 -38
  179. package/es/ProStep/constants.js +4 -1
  180. package/es/ProStep/index.js +166 -153
  181. package/es/ProStep/propsType.js +0 -1
  182. package/es/ProStep/utils/index.js +29 -55
  183. package/es/ProStepTab/index.js +83 -138
  184. package/es/ProStepTab/propsType.js +0 -1
  185. package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
  186. package/es/ProTable/components/EditableCell/index.js +37 -71
  187. package/es/ProTable/components/EditableCell/propsType.js +0 -1
  188. package/es/ProTable/components/FormatColumn/index.js +209 -340
  189. package/es/ProTable/components/FormatColumn/propsType.js +0 -1
  190. package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
  191. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
  192. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
  193. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
  194. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
  195. package/es/ProTable/components/RcTable/index.js +6 -4
  196. package/es/ProTable/components/RenderColumn/index.js +158 -186
  197. package/es/ProTable/components/RenderEmptyText/index.js +12 -21
  198. package/es/ProTable/components/RenderFooter/index.js +15 -15
  199. package/es/ProTable/components/RenderSummary/index.js +33 -50
  200. package/es/ProTable/components/RenderTableHeader/index.js +44 -46
  201. package/es/ProTable/components/RenderTabs/index.js +47 -51
  202. package/es/ProTable/components/TableResizable/index.js +56 -72
  203. package/es/ProTable/components/TooltipTitle/index.js +13 -21
  204. package/es/ProTable/components/index.js +16 -36
  205. package/es/ProTable/hooks/useAntdTable.js +185 -219
  206. package/es/ProTable/index.js +232 -249
  207. package/es/ProTable/propsType.js +0 -1
  208. package/es/ProTable/utils/columnStorage.js +63 -88
  209. package/es/ProTable/utils/index.js +57 -90
  210. package/es/ProTabs/components/Card/index.js +20 -48
  211. package/es/ProTabs/components/index.js +4 -1
  212. package/es/ProTabs/index.js +39 -56
  213. package/es/ProTabs/propType.js +0 -1
  214. package/es/ProThemeTools/component/ProTools/index.js +106 -158
  215. package/es/ProThemeTools/component/index.js +4 -1
  216. package/es/ProThemeTools/context/ThemeContext.js +67 -146
  217. package/es/ProThemeTools/index.js +103 -156
  218. package/es/ProThemeTools/propsType.js +0 -1
  219. package/es/ProThemeTools/utils/index.js +60 -109
  220. package/es/ProTooltip/index.js +132 -165
  221. package/es/ProTooltip/propsType.js +0 -1
  222. package/es/ProTree/components/AdaptiveTooltip.js +15 -17
  223. package/es/ProTree/components/CloseIcon.js +18 -26
  224. package/es/ProTree/components/List.js +28 -47
  225. package/es/ProTree/components/ProTree.js +152 -211
  226. package/es/ProTree/components/ProTreeSelect/index.js +254 -458
  227. package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
  228. package/es/ProTree/components/SearchTitle.js +23 -42
  229. package/es/ProTree/components/Tree.js +147 -195
  230. package/es/ProTree/components/index.js +10 -5
  231. package/es/ProTree/index.js +12 -16
  232. package/es/ProTree/propsType.js +0 -1
  233. package/es/ProTree/utils.js +46 -118
  234. package/es/ProTreeModal/components/Cascader.js +56 -64
  235. package/es/ProTreeModal/components/CloseIcon.js +18 -26
  236. package/es/ProTreeModal/components/List.js +114 -180
  237. package/es/ProTreeModal/components/SearchTitle.js +15 -18
  238. package/es/ProTreeModal/components/SortableItem.js +29 -58
  239. package/es/ProTreeModal/components/Tree.js +99 -113
  240. package/es/ProTreeModal/components/Trigger.js +87 -121
  241. package/es/ProTreeModal/components/index.js +14 -6
  242. package/es/ProTreeModal/index.js +397 -435
  243. package/es/ProTreeModal/propsType.js +0 -1
  244. package/es/ProTreeModal/utils.js +52 -95
  245. package/es/ProUpload/components/ButtonRender.js +44 -54
  246. package/es/ProUpload/components/DragRender.js +94 -134
  247. package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
  248. package/es/ProUpload/components/Example.js +27 -31
  249. package/es/ProUpload/components/FileItem.js +69 -163
  250. package/es/ProUpload/components/ImageRender.js +134 -170
  251. package/es/ProUpload/index.js +68 -100
  252. package/es/ProUpload/propsType.js +0 -1
  253. package/es/ProUpload/uitls.js +8 -4
  254. package/es/ProUtils/utils/index.js +17 -13
  255. package/es/ProViewer/index.js +154 -175
  256. package/es/ProViewer/propsType.js +0 -5
  257. package/es/ProWaterMark/index.js +9 -16
  258. package/es/ProWaterMark/propsType.js +0 -1
  259. package/es/hooks/useDraggableRow.js +25 -53
  260. package/es/index.js +57 -77
  261. package/es/locale/en_US.js +153 -142
  262. package/es/locale/index.js +23 -36
  263. package/es/locale/zh_CN.js +145 -142
  264. package/es/tokens.js +84 -83
  265. package/es/utils/index.js +24 -51
  266. package/package.json +4 -3
@@ -1,34 +1,48 @@
1
- import _isFunction from "lodash/isFunction";
2
- import _cloneDeep from "lodash/cloneDeep";
3
- import React, { useEffect, useMemo, useRef } from 'react';
4
- import { useDeepCompareEffect, useSetState, useRequest as useRequestFunc, useDebounceFn } from 'ahooks';
5
- import { Button, Checkbox, Input, message } from 'antd';
6
- import { ReactSVG } from 'react-svg';
7
- import classNames from 'classnames';
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import React, { useEffect, useMemo, useRef } from "react";
3
+ import {
4
+ useDeepCompareEffect,
5
+ useSetState,
6
+ useRequest as useRequestFunc,
7
+ useDebounceFn
8
+ } from "ahooks";
9
+ import { Button, Checkbox, Input, message } from "antd";
10
+ import cloneDeep from "lodash/cloneDeep";
11
+ import isFunction from "lodash/isFunction";
12
+ import { ReactSVG } from "react-svg";
13
+ import classNames from "classnames";
8
14
  import { ProDrawerForm, useProConfig } from "../index";
9
15
  import { Trigger, ListView, TreeView, Cascader } from "./components";
10
- import { getFlatTreeData, filterCheckedNodes, getChildrenKeys, findTreeNodeByKey, transformMessage, addLevelAndParentId } from "./utils";
11
- import { transformTreeToArray, treeNodeFind } from "../ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index";
16
+ import {
17
+ getFlatTreeData,
18
+ filterCheckedNodes,
19
+ getChildrenKeys,
20
+ findTreeNodeByKey,
21
+ transformMessage,
22
+ addLevelAndParentId
23
+ } from "./utils";
24
+ import {
25
+ transformTreeToArray,
26
+ treeNodeFind
27
+ } from "../ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index";
12
28
  import searchSVG from "../assets/input-search.svg";
13
29
  import locale, { formatMessage } from "../locale";
14
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
15
- const LIST = 'LIST';
16
- const TREE = 'TREE';
17
- export const CASCADER = 'CASCADER';
18
- const getSelectableValues = (flatTreeData, fieldNameValue) => flatTreeData.filter(item => item.disabled !== true).map(item => item[fieldNameValue]);
19
- const isAllSelectableChecked = (selectableValues, checkedValues) => selectableValues.length > 0 && selectableValues.every(selectableValue => checkedValues.includes(selectableValue));
30
+ const LIST = "LIST";
31
+ const TREE = "TREE";
32
+ const CASCADER = "CASCADER";
33
+ const getSelectableValues = (flatTreeData, fieldNameValue) => flatTreeData.filter((item) => item.disabled !== true).map((item) => item[fieldNameValue]);
34
+ const isAllSelectableChecked = (selectableValues, checkedValues) => selectableValues.length > 0 && selectableValues.every((selectableValue) => checkedValues.includes(selectableValue));
20
35
  const getSelectionState = (currentState, checkedValues, fieldNames) => {
21
36
  const selectableValues = getSelectableValues(currentState.flatTreeData, fieldNames.value);
22
37
  return {
23
38
  checkedValues,
24
- treeViewData: filterCheckedNodes(currentState.originalTreeData, checkedValues, '', fieldNames),
39
+ treeViewData: filterCheckedNodes(currentState.originalTreeData, checkedValues, "", fieldNames),
25
40
  checkAll: isAllSelectableChecked(selectableValues, checkedValues)
26
41
  };
27
42
  };
28
- const ProTreeModal = props => {
29
- const {
30
- dics = {}
31
- } = useProConfig('ProEnum');
43
+ const ProTreeModal = (props) => {
44
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
45
+ const { dics = {} } = useProConfig("ProEnum");
32
46
  const listRef = useRef(null);
33
47
  const {
34
48
  open: controlledOpen,
@@ -36,9 +50,9 @@ const ProTreeModal = props => {
36
50
  onChange,
37
51
  dataSource,
38
52
  trigger,
39
- mode = 'tree',
53
+ mode = "tree",
40
54
  code: enumCode,
41
- title = locale?.ProTreeModal?.select,
55
+ title = (_b = (_a = locale) == null ? void 0 : _a.ProTreeModal) == null ? void 0 : _b.select,
42
56
  useRequest,
43
57
  showCodeName = false,
44
58
  checkStrictly = false,
@@ -53,20 +67,18 @@ const ProTreeModal = props => {
53
67
  appoint,
54
68
  appointProps,
55
69
  fieldNames = {
56
- label: 'label',
57
- value: 'value',
58
- children: 'children'
70
+ label: "label",
71
+ value: "value",
72
+ children: "children"
59
73
  },
60
- disabled = props.disabled || props.isView || props?.otherProps?.isView || false,
61
- isView = props.isView || props?.otherProps?.isView || false,
74
+ disabled = props.disabled || props.isView || ((_c = props == null ? void 0 : props.otherProps) == null ? void 0 : _c.isView) || false,
75
+ isView = props.isView || ((_d = props == null ? void 0 : props.otherProps) == null ? void 0 : _d.isView) || false,
62
76
  transformResponse,
63
77
  optionRender,
64
78
  openChange,
65
79
  maxMessage
66
80
  } = props;
67
- let {
68
- allValue
69
- } = props;
81
+ let { allValue } = props;
70
82
  const modeType = mode.toUpperCase();
71
83
  const fieldNameLabel = fieldNames.label;
72
84
  const fieldNameValue = fieldNames.value;
@@ -75,10 +87,8 @@ const ProTreeModal = props => {
75
87
  if (!Array.isArray(items)) {
76
88
  return [];
77
89
  }
78
- return items.map(item => {
79
- const nextItem = {
80
- ...item
81
- };
90
+ return items.map((item) => {
91
+ const nextItem = { ...item };
82
92
  if (nextItem.fixed && !nextItem.disabled) {
83
93
  nextItem.disabled = true;
84
94
  }
@@ -90,27 +100,30 @@ const ProTreeModal = props => {
90
100
  });
91
101
  };
92
102
  if (appoint && !allValue) {
93
- console.error('allValue must be input');
94
- allValue = 'all';
103
+ console.error("allValue must be input");
104
+ allValue = "all";
95
105
  }
96
- const [{
97
- open,
98
- checkedValues,
99
- treeData,
100
- treeViewData,
101
- originalTreeData,
102
- flatTreeData,
103
- searchStr,
104
- checkAll,
105
- transformedTree
106
- }, setState] = useSetState({
106
+ const [
107
+ {
108
+ open,
109
+ checkedValues,
110
+ treeData,
111
+ treeViewData,
112
+ originalTreeData,
113
+ flatTreeData,
114
+ searchStr,
115
+ checkAll,
116
+ transformedTree
117
+ },
118
+ setState
119
+ ] = useSetState({
107
120
  open: false,
108
121
  checkedValues: [],
109
122
  treeData: [],
110
123
  treeViewData: [],
111
124
  originalTreeData: [],
112
125
  flatTreeData: [],
113
- searchStr: '',
126
+ searchStr: "",
114
127
  checkAll: false,
115
128
  transformedTree: []
116
129
  });
@@ -118,16 +131,16 @@ const ProTreeModal = props => {
118
131
  const previousControlledOpenRef = useRef(controlledOpen);
119
132
  const fieldNamesRef = useRef(fieldNames);
120
133
  fieldNamesRef.current = fieldNames;
121
- const selectableValues = useMemo(() => getSelectableValues(flatTreeData, fieldNameValue), [flatTreeData, fieldNameValue]);
122
- const fetchFunction = useRequestFunc(useRequest?.service, {
134
+ const selectableValues = useMemo(
135
+ () => getSelectableValues(flatTreeData, fieldNameValue),
136
+ [flatTreeData, fieldNameValue]
137
+ );
138
+ const fetchFunction = useRequestFunc(useRequest == null ? void 0 : useRequest.service, {
123
139
  manual: true,
124
- onSuccess: res => {
125
- const {
126
- status = 200,
127
- message: msg
128
- } = res;
129
- let responseData = res?.data;
130
- if (transformResponse && typeof transformResponse === 'function') {
140
+ onSuccess: (res) => {
141
+ const { status = 200, message: msg } = res;
142
+ let responseData = res == null ? void 0 : res.data;
143
+ if (transformResponse && typeof transformResponse === "function") {
131
144
  responseData = transformResponse(res);
132
145
  }
133
146
  if (status !== 200) {
@@ -141,68 +154,61 @@ const ProTreeModal = props => {
141
154
  });
142
155
  },
143
156
  debounceWait: 300,
144
- ...useRequest?.options
157
+ ...useRequest == null ? void 0 : useRequest.options
145
158
  });
146
159
  useDeepCompareEffect(() => {
160
+ var _a2, _b2;
147
161
  if (dataSource && dataSource.length) {
148
162
  const normalizedDataSource = normalizeFixedDisabled(dataSource);
149
- const flatTreeData = getFlatTreeData(normalizedDataSource, fieldNames);
163
+ const flatTreeData2 = getFlatTreeData(normalizedDataSource, fieldNames);
150
164
  setState({
151
165
  treeData: normalizedDataSource,
152
- originalTreeData: _cloneDeep(normalizedDataSource),
153
- flatTreeData
166
+ originalTreeData: cloneDeep(normalizedDataSource),
167
+ flatTreeData: flatTreeData2
154
168
  });
155
169
  } else if (enumCode) {
156
170
  let dictEnum = dics[enumCode] || [];
157
- // transform dictEnum
158
- if (transformResponse && _isFunction(transformResponse)) {
171
+ if (transformResponse && isFunction(transformResponse)) {
159
172
  dictEnum = transformResponse(dictEnum);
160
173
  }
161
- // check dictEnum isArray
162
174
  if (!dictEnum || !Array.isArray(dictEnum)) {
163
- console.error(locale?.ProTreeModal?.errorArrayMessage);
175
+ console.error((_b2 = (_a2 = locale) == null ? void 0 : _a2.ProTreeModal) == null ? void 0 : _b2.errorArrayMessage);
164
176
  dictEnum = [];
165
177
  }
166
178
  const normalizedDictEnum = normalizeFixedDisabled(dictEnum);
167
179
  setState({
168
180
  treeData: normalizedDictEnum,
169
- originalTreeData: _cloneDeep(normalizedDictEnum),
181
+ originalTreeData: cloneDeep(normalizedDictEnum),
170
182
  flatTreeData: getFlatTreeData(normalizedDictEnum, fieldNames)
171
183
  });
172
184
  }
173
185
  }, [dataSource, enumCode]);
174
186
  useDeepCompareEffect(() => {
175
187
  if (enumCode) {
176
- return undefined;
188
+ return void 0;
177
189
  }
178
190
  if (dataSource) {
179
- return undefined;
191
+ return void 0;
180
192
  }
181
- const {
182
- defaultParams,
183
- manual
184
- } = useRequest?.options || {};
185
- const params = Array.isArray(defaultParams) ? defaultParams?.[0] : defaultParams || {};
193
+ const { defaultParams, manual } = (useRequest == null ? void 0 : useRequest.options) || {};
194
+ const params = Array.isArray(defaultParams) ? defaultParams == null ? void 0 : defaultParams[0] : defaultParams || {};
186
195
  if (manual) {
187
196
  return;
188
197
  }
189
- // 执行用户配置的枚举服务,拉取枚举数据进行更新
190
198
  fetchFunction.run(params);
191
- }, [useRequest?.options]);
199
+ }, [useRequest == null ? void 0 : useRequest.options]);
192
200
  useEffect(() => {
193
201
  const wasControlledOpen = previousControlledOpenRef.current === true;
194
202
  if (controlledOpen === true && !wasControlledOpen) {
195
- setState(prevState => {
203
+ setState((prevState) => {
196
204
  openSnapshotValuesRef.current = [...prevState.checkedValues];
197
- return {
198
- open: true
199
- };
205
+ return { open: true };
200
206
  });
201
207
  } else if (controlledOpen === false && wasControlledOpen) {
202
- const checkedValues = [...openSnapshotValuesRef.current];
203
- setState(prevState => ({
208
+ const checkedValues2 = [...openSnapshotValuesRef.current];
209
+ setState((prevState) => ({
204
210
  open: false,
205
- ...getSelectionState(prevState, checkedValues, fieldNamesRef.current)
211
+ ...getSelectionState(prevState, checkedValues2, fieldNamesRef.current)
206
212
  }));
207
213
  } else {
208
214
  setState({
@@ -215,26 +221,27 @@ const ProTreeModal = props => {
215
221
  if (value) {
216
222
  let nextCheckedValues = [];
217
223
  let nextTreeViewData = [];
218
- if (allValue && typeof value === 'string' && allValue === value) {
224
+ if (allValue && typeof value === "string" && allValue === value) {
219
225
  nextCheckedValues = selectableValues;
220
226
  } else {
221
227
  if (!Array.isArray(value)) {
222
- console.error('Please pass in the array');
228
+ console.error("Please pass in the array");
223
229
  return;
224
230
  }
225
- // 开启 labelInValue [{ label:xx, value: ""}] 形式、需要取出来 value
226
231
  if (labelInValue) {
227
- const isObjectArray = value.every(element => typeof element === 'object' && element !== null);
232
+ const isObjectArray = value.every(
233
+ (element) => typeof element === "object" && element !== null
234
+ );
228
235
  if (!isObjectArray) {
229
- console.error('Please enter an array object');
236
+ console.error("Please enter an array object");
230
237
  nextCheckedValues = [];
231
238
  }
232
- nextCheckedValues = value.map(item => item[fieldNameValue]);
239
+ nextCheckedValues = value.map((item) => item[fieldNameValue]);
233
240
  } else {
234
241
  nextCheckedValues = value;
235
242
  }
236
243
  }
237
- nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, '', fieldNames);
244
+ nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, "", fieldNames);
238
245
  openSnapshotValuesRef.current = [...nextCheckedValues];
239
246
  setState({
240
247
  checkedValues: nextCheckedValues,
@@ -242,11 +249,9 @@ const ProTreeModal = props => {
242
249
  treeViewData: nextTreeViewData
243
250
  });
244
251
  } else if (modeType === LIST && flatTreeData && flatTreeData.length > 0) {
245
- // mode: 'list' 下,如果没有 value prop,自动将 fixed 的项加入到 checkedValues
246
- const fixedItems = flatTreeData.filter(item => item.fixed === 'right').map(item => item[fieldNameValue]);
252
+ const fixedItems = flatTreeData.filter((item) => item.fixed === "right").map((item) => item[fieldNameValue]);
247
253
  if (fixedItems.length > 0 && checkedValues.length === 0) {
248
- // 只有当 checkedValues 为空时才自动添加 fixed 项,避免覆盖已有的选中状态
249
- const nextTreeViewData = filterCheckedNodes(originalTreeData, fixedItems, '', fieldNames);
254
+ const nextTreeViewData = filterCheckedNodes(originalTreeData, fixedItems, "", fieldNames);
250
255
  openSnapshotValuesRef.current = [...fixedItems];
251
256
  setState({
252
257
  checkedValues: fixedItems,
@@ -267,54 +272,43 @@ const ProTreeModal = props => {
267
272
  setState({
268
273
  open: true
269
274
  });
270
- openChange?.(true);
275
+ openChange == null ? void 0 : openChange(true);
271
276
  };
272
-
273
- /**
274
- * close Drawer and onChange(values)
275
- */
276
277
  const handleFinish = () => {
278
+ var _a2, _b2, _c2;
277
279
  if (draggable && span) {
278
- // 开启 draggable 使用拖拽后的顺序
279
- const checkedList = listRef.current?.onChange();
280
- onChange?.(checkedList);
280
+ const checkedList = (_a2 = listRef.current) == null ? void 0 : _a2.onChange();
281
+ onChange == null ? void 0 : onChange(checkedList);
281
282
  } else {
282
283
  let values = checkedValues;
283
284
  if (labelInValue) {
284
285
  values = [];
285
- checkedValues.forEach(val => {
286
- const option = flatTreeData.find(item => item[fieldNameValue] === val);
286
+ checkedValues.forEach((val) => {
287
+ const option = flatTreeData.find((item) => item[fieldNameValue] === val);
287
288
  option && values.push(option);
288
289
  });
289
290
  }
290
- const skipMinCheck = allValue !== undefined && checkAll && !draggable;
291
+ const skipMinCheck = allValue !== void 0 && checkAll && !draggable;
291
292
  if (!skipMinCheck && min && values.length < min) {
292
- message.error(formatMessage(locale?.ProTreeModal?.selectMin, {
293
- min
294
- }));
293
+ message.error(formatMessage((_c2 = (_b2 = locale) == null ? void 0 : _b2.ProTreeModal) == null ? void 0 : _c2.selectMin, { min }));
295
294
  return;
296
295
  }
297
- onChange?.(values);
296
+ onChange == null ? void 0 : onChange(values);
298
297
  }
299
298
  openSnapshotValuesRef.current = [...checkedValues];
300
- // fix: 当有 openChange 时候、点击确定应该由关闭 openChange 控制
301
- if (!openChange || controlledOpen === undefined) {
299
+ if (!openChange || controlledOpen === void 0) {
302
300
  setState({
303
301
  open: false
304
302
  });
305
- openChange?.(false);
303
+ openChange == null ? void 0 : openChange(false);
306
304
  }
307
- if (openChange && controlledOpen !== undefined) {
308
- openChange?.(true);
305
+ if (openChange && controlledOpen !== void 0) {
306
+ openChange == null ? void 0 : openChange(true);
309
307
  }
310
308
  };
311
-
312
- /**
313
- * clear all checked
314
- */
315
309
  const handleClearAll = (immediateSubmit = false) => {
316
- // 处理 ProTable 场景下 disabled 的不需要被清理
317
- const nextCheckedValues = span ? flatTreeData.filter(item => item.disabled)?.map(item => item[fieldNameValue]) : [];
310
+ var _a2;
311
+ const nextCheckedValues = span ? (_a2 = flatTreeData.filter((item) => item.disabled)) == null ? void 0 : _a2.map((item) => item[fieldNameValue]) : [];
318
312
  setState({
319
313
  checkedValues: nextCheckedValues,
320
314
  treeViewData: [],
@@ -323,40 +317,31 @@ const ProTreeModal = props => {
323
317
  if (immediateSubmit) {
324
318
  openSnapshotValuesRef.current = [...nextCheckedValues];
325
319
  if (labelInValue) {
326
- onChange?.([]);
320
+ onChange == null ? void 0 : onChange([]);
327
321
  } else {
328
- onChange?.(nextCheckedValues);
322
+ onChange == null ? void 0 : onChange(nextCheckedValues);
329
323
  }
330
324
  }
331
325
  };
332
-
333
- /**
334
- * Drawer close
335
- */
336
326
  const handleClose = () => {
337
327
  const restoredCheckedValues = [...openSnapshotValuesRef.current];
338
- setState(prevState => ({
328
+ setState((prevState) => ({
339
329
  open: false,
340
330
  ...getSelectionState(prevState, restoredCheckedValues, fieldNames)
341
331
  }));
342
- openChange?.(false);
332
+ openChange == null ? void 0 : openChange(false);
343
333
  };
344
-
345
- /**
346
- * checkbox/list selected change values
347
- * @param values
348
- */
349
334
  const handleListCheckChange = (e, code) => {
335
+ var _a2, _b2;
350
336
  let nextCheckedValues = [...checkedValues];
351
- const {
352
- checked
353
- } = e.target;
337
+ const { checked } = e.target;
354
338
  if (!checked) {
355
- nextCheckedValues = nextCheckedValues.filter(value => value !== code);
339
+ nextCheckedValues = nextCheckedValues.filter((value2) => value2 !== code);
356
340
  } else if (draggable && span) {
357
- // 固定在右侧的情况
358
- const fixedOption = flatTreeData.find(item => item.fixed === 'right') || {};
359
- const fixedIdx = nextCheckedValues.findIndex(value => value === fixedOption[fieldNameValue]);
341
+ const fixedOption = flatTreeData.find((item) => item.fixed === "right") || {};
342
+ const fixedIdx = nextCheckedValues.findIndex(
343
+ (value2) => value2 === fixedOption[fieldNameValue]
344
+ );
360
345
  if (fixedIdx >= 0) {
361
346
  nextCheckedValues.splice(fixedIdx, 0, code);
362
347
  } else {
@@ -366,11 +351,9 @@ const ProTreeModal = props => {
366
351
  nextCheckedValues.push(code);
367
352
  }
368
353
  if (max && nextCheckedValues.length > max) {
369
- message.error(maxMessage ? transformMessage({
370
- max
371
- }, maxMessage) : formatMessage(locale?.ProTreeModal?.selectMax, {
372
- max
373
- }));
354
+ message.error(
355
+ maxMessage ? transformMessage({ max }, maxMessage) : formatMessage((_b2 = (_a2 = locale) == null ? void 0 : _a2.ProTreeModal) == null ? void 0 : _b2.selectMax, { max })
356
+ );
374
357
  return;
375
358
  }
376
359
  setState({
@@ -378,44 +361,45 @@ const ProTreeModal = props => {
378
361
  checkAll: isAllSelectableChecked(selectableValues, nextCheckedValues)
379
362
  });
380
363
  };
381
- const handleDragEndChange = checkedValues => {
364
+ const handleDragEndChange = (checkedValues2) => {
382
365
  setState({
383
- checkedValues
366
+ checkedValues: checkedValues2
384
367
  });
385
368
  };
386
369
  const onCheck = (checkedKeys, info) => {
370
+ var _a2, _b2, _c2;
387
371
  let nextCheckedValues = [...checkedValues];
388
-
389
- // 如果有检索则自管理
390
372
  if (searchStr) {
391
- const {
392
- node
393
- } = info;
394
- // 从完整树中找到当前节点
395
- const activeNode = treeNodeFind(transformedTree, t => t[fieldNameValue] === node[fieldNameValue], {
396
- childrenKey: fieldNames.children
397
- });
398
- const allChildren = transformTreeToArray([activeNode], {
373
+ const { node } = info;
374
+ const activeNode = treeNodeFind(
375
+ transformedTree,
376
+ (t) => t[fieldNameValue] === node[fieldNameValue],
377
+ {
378
+ childrenKey: fieldNames.children
379
+ }
380
+ );
381
+ const allChildren = (_a2 = transformTreeToArray([activeNode], {
399
382
  childrenKey: fieldNames.children
400
- })?.map(item => item[fieldNameValue]);
401
- // 子项合并勾选
383
+ })) == null ? void 0 : _a2.map((item) => item[fieldNameValue]);
402
384
  nextCheckedValues = nextCheckedValues.concat(allChildren);
403
- // 从完整树中拿到父节点 只要存在父节点,那么就判断当前children是否全被勾选 若全被勾选就合并当前key到勾选队列
404
- const appendCheckedParentKeys = findNode => {
385
+ const appendCheckedParentKeys = (findNode) => {
386
+ var _a3;
405
387
  if (findNode.parentId) {
406
- const parentNode = treeNodeFind(transformedTree, t => t[fieldNameValue] === findNode.parentId, {
407
- childrenKey: fieldNames.children
408
- });
409
- const parentChildrenKeys = transformTreeToArray([parentNode], {
388
+ const parentNode = treeNodeFind(
389
+ transformedTree,
390
+ (t) => t[fieldNameValue] === findNode.parentId,
391
+ {
392
+ childrenKey: fieldNames.children
393
+ }
394
+ );
395
+ const parentChildrenKeys = (_a3 = transformTreeToArray([parentNode], {
410
396
  childrenKey: fieldNames.children
411
- })?.map(item => item[fieldNameValue]);
412
- const parentChildrenAllChecked = parentChildrenKeys.every(key => {
397
+ })) == null ? void 0 : _a3.map((item) => item[fieldNameValue]);
398
+ const parentChildrenAllChecked = parentChildrenKeys.every((key) => {
413
399
  return nextCheckedValues.includes(key);
414
400
  });
415
401
  if (parentChildrenAllChecked) {
416
- // 把当前父节点追加进来
417
402
  nextCheckedValues = nextCheckedValues.concat([parentNode[fieldNameValue]]);
418
- // 继续向上查找
419
403
  if (parentNode.parentId) {
420
404
  appendCheckedParentKeys(parentNode);
421
405
  }
@@ -425,50 +409,42 @@ const ProTreeModal = props => {
425
409
  appendCheckedParentKeys(activeNode);
426
410
  }
427
411
  const effectiveCheckStrictly = searchStr ? true : checkStrictly;
428
-
429
- // 此时应该取消掉自身并包含它所有的子集
430
412
  if (!info.checked && !effectiveCheckStrictly) {
431
- // 1. 取消自身
432
- // 2. 把所有的子节点也要取消
433
413
  const childrenKeys = [];
434
- getChildrenKeys(info.node, childrenKeys, fieldNames, 'treeCheck');
435
- nextCheckedValues = nextCheckedValues.filter(key => !childrenKeys.includes(key));
436
-
437
- // 3. 取消父节点
414
+ getChildrenKeys(info.node, childrenKeys, fieldNames, "treeCheck");
415
+ nextCheckedValues = nextCheckedValues.filter((key) => !childrenKeys.includes(key));
438
416
  const parentNodes = findTreeNodeByKey(originalTreeData, info.node.key, fieldNames);
439
- const parentKeys = parentNodes.reduce((prev, curr) => prev.concat(curr[fieldNameValue]), []);
440
- nextCheckedValues = nextCheckedValues.filter(key => !parentKeys.includes(key));
417
+ const parentKeys = parentNodes.reduce(
418
+ (prev, curr) => prev.concat(curr[fieldNameValue]),
419
+ []
420
+ );
421
+ nextCheckedValues = nextCheckedValues.filter((key) => !parentKeys.includes(key));
441
422
  } else {
442
- // checkStrictly 模式下取 checkedKeys.checked 或者自身的 key
443
423
  if (effectiveCheckStrictly) {
444
424
  if (!info.checked) {
445
- nextCheckedValues = nextCheckedValues.filter(key => key !== info.node.key);
425
+ nextCheckedValues = nextCheckedValues.filter((key) => key !== info.node.key);
446
426
  }
447
427
  checkedKeys = checkedKeys.checked || [];
448
428
  }
449
- checkedKeys.forEach(key => {
429
+ checkedKeys.forEach((key) => {
450
430
  const exist = nextCheckedValues.includes(key);
451
431
  if (info.checked && !exist) {
452
432
  nextCheckedValues.push(key);
453
433
  }
454
434
  });
455
435
  }
456
-
457
- // 根据选中的筛选出 viewTreeData
458
436
  let nextTreeViewData = [];
459
437
  if (!checkStrictly) {
460
- nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, '', fieldNames);
438
+ nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, "", fieldNames);
461
439
  } else {
462
- nextTreeViewData = flatTreeData.filter(item => {
440
+ nextTreeViewData = flatTreeData.filter((item) => {
463
441
  return nextCheckedValues.includes(item[fieldNameValue]);
464
442
  });
465
443
  }
466
444
  if (max && nextCheckedValues.length > max) {
467
- message.error(maxMessage ? transformMessage({
468
- max
469
- }, maxMessage) : formatMessage(locale?.ProTreeModal?.selectMax, {
470
- max
471
- }));
445
+ message.error(
446
+ maxMessage ? transformMessage({ max }, maxMessage) : formatMessage((_c2 = (_b2 = locale) == null ? void 0 : _b2.ProTreeModal) == null ? void 0 : _c2.selectMax, { max })
447
+ );
472
448
  return;
473
449
  }
474
450
  setState({
@@ -477,47 +453,32 @@ const ProTreeModal = props => {
477
453
  checkAll: isAllSelectableChecked(selectableValues, nextCheckedValues)
478
454
  });
479
455
  };
480
-
481
- /**
482
- * filter checkbox by fileNameValue
483
- * @param fileNameValue
484
- */
485
- const handleFilterClose = fileNameValue => {
456
+ const handleFilterClose = (fileNameValue) => {
486
457
  setState({
487
- checkedValues: checkedValues.filter(value => value !== fileNameValue),
458
+ checkedValues: checkedValues.filter((value2) => value2 !== fileNameValue),
488
459
  checkAll: false
489
460
  });
490
461
  };
491
-
492
- /**
493
- * tree close
494
- * @param fileNamekey
495
- * @param node
496
- */
497
462
  const treeFilterClose = (fileNamekey, node) => {
498
463
  let nextCheckedValues = [...checkedValues];
499
464
  let nextTreeViewData = [];
500
465
  if (checkStrictly) {
501
- nextCheckedValues = nextCheckedValues.filter(key => key !== fileNamekey);
502
- // handleFilterClose
503
- nextTreeViewData = flatTreeData.filter(item => {
466
+ nextCheckedValues = nextCheckedValues.filter((key) => key !== fileNamekey);
467
+ nextTreeViewData = flatTreeData.filter((item) => {
504
468
  return nextCheckedValues.includes(item[fieldNameValue]);
505
469
  });
506
470
  } else {
507
- // 1. 取消自身
508
- nextCheckedValues = nextCheckedValues.filter(key => key !== fileNamekey);
509
- // 2. 把所有的子节点也要取消
471
+ nextCheckedValues = nextCheckedValues.filter((key) => key !== fileNamekey);
510
472
  const childrenKeys = [];
511
- getChildrenKeys(node, childrenKeys, fieldNames, 'treeClose');
512
- nextCheckedValues = nextCheckedValues.filter(key => !childrenKeys.includes(key));
513
-
514
- // 3. 取消父节点
473
+ getChildrenKeys(node, childrenKeys, fieldNames, "treeClose");
474
+ nextCheckedValues = nextCheckedValues.filter((key) => !childrenKeys.includes(key));
515
475
  const parentNodes = findTreeNodeByKey(originalTreeData, fileNamekey, fieldNames);
516
- const parentKeys = parentNodes.reduce((prev, curr) => prev.concat(curr[fieldNames.value]), []);
517
- nextCheckedValues = nextCheckedValues.filter(key => !parentKeys.includes(key));
518
-
519
- // 根据选中的筛选出 viewTreeData
520
- nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, '', fieldNames);
476
+ const parentKeys = parentNodes.reduce(
477
+ (prev, curr) => prev.concat(curr[fieldNames.value]),
478
+ []
479
+ );
480
+ nextCheckedValues = nextCheckedValues.filter((key) => !parentKeys.includes(key));
481
+ nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, "", fieldNames);
521
482
  }
522
483
  setState({
523
484
  checkedValues: nextCheckedValues,
@@ -525,109 +486,94 @@ const ProTreeModal = props => {
525
486
  checkAll: false
526
487
  });
527
488
  };
528
- const {
529
- run: onSearch
530
- } = useDebounceFn(str => {
531
- if (modeType === LIST || modeType === CASCADER) {
532
- const isCASCADER = modeType === CASCADER;
533
- const filteredData = flatTreeData.filter(item => {
534
- const title = isCASCADER ? item?.title : item[fieldNameLabel];
535
- return title.includes(str);
536
- });
537
- setState({
538
- treeData: !str ? originalTreeData : filteredData
539
- });
489
+ const { run: onSearch } = useDebounceFn(
490
+ (str) => {
491
+ if (modeType === LIST || modeType === CASCADER) {
492
+ const isCASCADER = modeType === CASCADER;
493
+ const filteredData = flatTreeData.filter((item) => {
494
+ const title2 = isCASCADER ? item == null ? void 0 : item.title : item[fieldNameLabel];
495
+ return title2.includes(str);
496
+ });
497
+ setState({
498
+ treeData: !str ? originalTreeData : filteredData
499
+ });
500
+ }
501
+ },
502
+ {
503
+ wait: 0
540
504
  }
541
- }, {
542
- wait: 0
543
- });
544
- const handleSetSearchStr = str => {
505
+ );
506
+ const handleSetSearchStr = (str) => {
545
507
  setState({
546
508
  searchStr: str
547
509
  });
548
510
  onSearch(str);
549
511
  };
550
-
551
- /**
552
- * 指定模式下的操作
553
- * @param appoint
554
- */
555
- const appointChange = appoint => {
556
- if (appoint) {
557
- onChange?.(allValue);
512
+ const appointChange = (appoint2) => {
513
+ if (appoint2) {
514
+ onChange == null ? void 0 : onChange(allValue);
558
515
  setState({
559
516
  checkAll: true
560
517
  });
561
518
  } else {
562
- onChange?.([]);
519
+ onChange == null ? void 0 : onChange([]);
563
520
  setState({
564
521
  checkAll: false,
565
522
  open: true
566
523
  });
567
524
  }
568
525
  };
569
-
570
- /**
571
- * Trigger the container opened by Drawer
572
- * default example and you can customize trigger={<Button>打开</Button>}
573
- * @returns
574
- */
575
526
  const TriggerComponent = useMemo(() => {
576
- if (trigger && /*#__PURE__*/React.isValidElement(trigger)) {
577
- return /*#__PURE__*/_jsx("div", {
578
- onClick: handleClick,
579
- children: trigger
580
- });
527
+ var _a2;
528
+ if (trigger && React.isValidElement(trigger)) {
529
+ return /* @__PURE__ */ jsx("div", { onClick: handleClick, children: trigger });
581
530
  }
582
- return /*#__PURE__*/_jsx(Trigger, {
583
- checkedValues: checkedValues,
584
- value: value,
585
- checkAll: checkAll,
586
- triggerStyle: style,
587
- disabled: disabled,
588
- isView: isView,
589
- appoint: appoint,
590
- allValue: allValue,
591
- label: props?.otherProps?.label,
592
- handleClick: handleClick,
593
- handleClearAll: () => handleClearAll(true),
594
- appointChange: appointChange,
595
- appointProps: appointProps
596
- });
531
+ return /* @__PURE__ */ jsx(
532
+ Trigger,
533
+ {
534
+ checkedValues,
535
+ value,
536
+ checkAll,
537
+ triggerStyle: style,
538
+ disabled,
539
+ isView,
540
+ appoint,
541
+ allValue,
542
+ label: (_a2 = props == null ? void 0 : props.otherProps) == null ? void 0 : _a2.label,
543
+ handleClick,
544
+ handleClearAll: () => handleClearAll(true),
545
+ appointChange,
546
+ appointProps
547
+ }
548
+ );
597
549
  }, [checkedValues, checkAll, style, disabled, isView, value]);
598
-
599
- /**
600
- * 全选操作
601
- */
602
- const handleAllCheck = e => {
603
- const {
604
- checked
605
- } = e.target;
550
+ const handleAllCheck = (e) => {
551
+ var _a2, _b2;
552
+ const { checked } = e.target;
606
553
  let nextCheckedValues = [];
607
554
  let nextTreeViewData = [];
608
555
  if (checked) {
609
- nextCheckedValues = flatTreeData.filter(item => item.disabled !== true || checkedValues.includes(item[fieldNameValue])).map(item => item[fieldNameValue]);
556
+ nextCheckedValues = flatTreeData.filter((item) => item.disabled !== true || checkedValues.includes(item[fieldNameValue])).map((item) => item[fieldNameValue]);
610
557
  } else if (modeType === LIST || modeType === CASCADER) {
611
558
  if (span) {
612
- // ProTable 场景下 disabled 不取消掉
613
- nextCheckedValues = flatTreeData.filter(item => item.disabled).map(item => item[fieldNameValue]);
559
+ nextCheckedValues = flatTreeData.filter((item) => item.disabled).map((item) => item[fieldNameValue]);
614
560
  } else {
615
561
  nextCheckedValues = [];
616
562
  }
617
563
  }
618
564
  if (modeType === TREE) {
619
565
  if (checkStrictly) {
620
- nextTreeViewData = flatTreeData.filter(item => nextCheckedValues.includes(item[fieldNameValue]));
566
+ nextTreeViewData = flatTreeData.filter(
567
+ (item) => nextCheckedValues.includes(item[fieldNameValue])
568
+ );
621
569
  } else {
622
- nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, '', fieldNames);
570
+ nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, "", fieldNames);
623
571
  }
624
572
  }
625
573
  if (max && nextCheckedValues.length > max) {
626
- message.error(maxMessage ? transformMessage({
627
- max
628
- }, maxMessage) : formatMessage(locale?.ProTreeModal?.selectMax, {
629
- max
630
- }));
574
+ message.error(
575
+ maxMessage ? transformMessage({ max }, maxMessage) : formatMessage((_b2 = (_a2 = locale) == null ? void 0 : _a2.ProTreeModal) == null ? void 0 : _b2.selectMax, { max })
576
+ );
631
577
  return;
632
578
  }
633
579
  setState({
@@ -636,189 +582,205 @@ const ProTreeModal = props => {
636
582
  treeViewData: nextTreeViewData
637
583
  });
638
584
  };
639
-
640
- /**
641
- * 左侧容器、分为三种 list、tree、Cascader
642
- * @returns
643
- */
644
585
  const renderContainer = () => {
586
+ var _a2, _b2;
645
587
  if (treeData.length === 0 && searchStr) {
646
- return /*#__PURE__*/_jsx("div", {
647
- className: "pro-tree-modal-no-checks",
648
- children: locale?.ProTreeModal?.noFinal
649
- });
588
+ return /* @__PURE__ */ jsx("div", { className: "pro-tree-modal-no-checks", children: (_b2 = (_a2 = locale) == null ? void 0 : _a2.ProTreeModal) == null ? void 0 : _b2.noFinal });
650
589
  }
651
590
  switch (modeType) {
652
591
  case LIST:
653
- return /*#__PURE__*/_jsx(ListView, {
654
- treeData: treeData,
655
- optionRender: optionRender,
656
- checkedValues: checkedValues,
657
- handleOnChange: handleListCheckChange,
658
- searchStr: searchStr,
659
- showCodeName: showCodeName,
660
- disabled: disabled || isView,
661
- fieldNames: fieldNames,
662
- span: span
663
- });
592
+ return /* @__PURE__ */ jsx(
593
+ ListView,
594
+ {
595
+ treeData,
596
+ optionRender,
597
+ checkedValues,
598
+ handleOnChange: handleListCheckChange,
599
+ searchStr,
600
+ showCodeName,
601
+ disabled: disabled || isView,
602
+ fieldNames,
603
+ span
604
+ }
605
+ );
664
606
  case TREE:
665
- return /*#__PURE__*/_jsx(TreeView, {
666
- treeData: transformedTree,
667
- originalTreeData: originalTreeData,
668
- flatTreeData: flatTreeData,
669
- checkedValues: checkedValues,
670
- onCheck: onCheck,
671
- optionRender: optionRender,
672
- searchStr: searchStr,
673
- showCodeName: showCodeName,
674
- disabled: disabled || isView,
675
- checkStrictly: checkStrictly,
676
- tags: tags,
677
- fieldNames: fieldNames
678
- });
607
+ return /* @__PURE__ */ jsx(
608
+ TreeView,
609
+ {
610
+ treeData: transformedTree,
611
+ originalTreeData,
612
+ flatTreeData,
613
+ checkedValues,
614
+ onCheck,
615
+ optionRender,
616
+ searchStr,
617
+ showCodeName,
618
+ disabled: disabled || isView,
619
+ checkStrictly,
620
+ tags,
621
+ fieldNames
622
+ }
623
+ );
679
624
  case CASCADER:
680
625
  if (searchStr && treeData.length) {
681
- return /*#__PURE__*/_jsx(ListView, {
682
- treeData: treeData,
683
- modeType: CASCADER,
684
- optionRender: optionRender,
685
- checkedValues: checkedValues,
686
- handleOnChange: handleListCheckChange,
687
- searchStr: searchStr,
688
- showCodeName: showCodeName,
689
- disabled: disabled || isView,
690
- fieldNames: fieldNames
691
- });
626
+ return /* @__PURE__ */ jsx(
627
+ ListView,
628
+ {
629
+ treeData,
630
+ modeType: CASCADER,
631
+ optionRender,
632
+ checkedValues,
633
+ handleOnChange: handleListCheckChange,
634
+ searchStr,
635
+ showCodeName,
636
+ disabled: disabled || isView,
637
+ fieldNames
638
+ }
639
+ );
692
640
  }
693
- return /*#__PURE__*/_jsx(Cascader, {
694
- dataSource: treeData,
695
- fieldNames: fieldNames,
696
- checkedValues: checkedValues,
697
- searchStr: searchStr,
698
- showCodeName: showCodeName,
699
- handleOnChange: handleListCheckChange,
700
- optionRender: optionRender
701
- });
641
+ return /* @__PURE__ */ jsx(
642
+ Cascader,
643
+ {
644
+ dataSource: treeData,
645
+ fieldNames,
646
+ checkedValues,
647
+ searchStr,
648
+ showCodeName,
649
+ handleOnChange: handleListCheckChange,
650
+ optionRender
651
+ }
652
+ );
702
653
  default:
703
654
  break;
704
655
  }
705
656
  };
706
657
  const listTreeData = useMemo(() => {
707
658
  const checkListOptions = [];
708
- checkedValues.forEach(key => {
709
- const option = flatTreeData.find(item => item[fieldNameValue] === key);
659
+ checkedValues.forEach((key) => {
660
+ const option = flatTreeData.find((item) => item[fieldNameValue] === key);
710
661
  if (option) {
711
662
  checkListOptions.push(option);
712
663
  }
713
664
  });
714
665
  return checkListOptions;
715
666
  }, [checkedValues, flatTreeData]);
716
-
717
- /**
718
- * 勾选后的右侧展示
719
- * @returns
720
- */
721
667
  const renderView = () => {
668
+ var _a2, _b2;
722
669
  if (checkedValues.length === 0) {
723
- return /*#__PURE__*/_jsx("div", {
724
- className: "pro-tree-modal-no-checks",
725
- children: locale?.ProTreeModal?.noCheck
726
- });
670
+ return /* @__PURE__ */ jsx("div", { className: "pro-tree-modal-no-checks", children: (_b2 = (_a2 = locale) == null ? void 0 : _a2.ProTreeModal) == null ? void 0 : _b2.noCheck });
727
671
  }
728
672
  switch (modeType) {
729
673
  case LIST:
730
674
  case CASCADER:
731
- return /*#__PURE__*/_jsx(ListView, {
732
- mode: "view",
733
- showCodeName: showCodeName,
734
- treeData: listTreeData,
735
- fieldNames: fieldNames,
736
- disabled: disabled || isView,
737
- draggable: draggable,
738
- flatTreeData: flatTreeData,
739
- span: span,
740
- ref: listRef,
741
- optionRender: optionRender,
742
- handleFilterClose: handleFilterClose,
743
- handleDragEndChange: handleDragEndChange
744
- });
675
+ return /* @__PURE__ */ jsx(
676
+ ListView,
677
+ {
678
+ mode: "view",
679
+ showCodeName,
680
+ treeData: listTreeData,
681
+ fieldNames,
682
+ disabled: disabled || isView,
683
+ draggable,
684
+ flatTreeData,
685
+ span,
686
+ ref: listRef,
687
+ optionRender,
688
+ handleFilterClose,
689
+ handleDragEndChange
690
+ }
691
+ );
745
692
  case TREE:
746
- return /*#__PURE__*/_jsx(TreeView, {
747
- mode: "view",
748
- checkStrictly: checkStrictly,
749
- showCodeName: showCodeName,
750
- treeData: checkStrictly ? listTreeData : treeViewData,
751
- tags: tags,
752
- fieldNames: fieldNames,
753
- disabled: disabled || isView,
754
- draggable: draggable,
755
- min: min,
756
- max: max,
757
- ref: listRef,
758
- handleFilterClose: treeFilterClose,
759
- optionRender: optionRender,
760
- handleDragEndChange: handleDragEndChange
761
- });
693
+ return /* @__PURE__ */ jsx(
694
+ TreeView,
695
+ {
696
+ mode: "view",
697
+ checkStrictly,
698
+ showCodeName,
699
+ treeData: checkStrictly ? listTreeData : treeViewData,
700
+ tags,
701
+ fieldNames,
702
+ disabled: disabled || isView,
703
+ draggable,
704
+ min,
705
+ max,
706
+ ref: listRef,
707
+ handleFilterClose: treeFilterClose,
708
+ optionRender,
709
+ handleDragEndChange
710
+ }
711
+ );
762
712
  default:
763
713
  break;
764
714
  }
765
715
  };
766
- return /*#__PURE__*/_jsx(_Fragment, {
767
- children: /*#__PURE__*/_jsxs("div", {
768
- className: "pro-tree-modal",
769
- children: [controlledOpen === undefined && TriggerComponent, /*#__PURE__*/_jsx(ProDrawerForm, {
716
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "pro-tree-modal", children: [
717
+ controlledOpen === void 0 && TriggerComponent,
718
+ /* @__PURE__ */ jsx(
719
+ ProDrawerForm,
720
+ {
770
721
  onOk: handleFinish,
771
722
  onCancel: handleClose,
772
723
  okDisabled: disabled,
773
- open: open,
774
- title: title,
724
+ open,
725
+ title,
775
726
  mode: "Modal",
776
727
  className: "pro-tree-modal-container",
777
- extraLeft: allValue !== undefined && !isView ? /*#__PURE__*/_jsx(Checkbox, {
778
- checked: checkAll,
779
- disabled: disabled,
780
- onChange: handleAllCheck,
781
- children: locale?.ProTreeModal?.checkAll
782
- }) : null,
783
- children: /*#__PURE__*/_jsxs("div", {
784
- className: "pro-tree-modal-content",
785
- children: [/*#__PURE__*/_jsxs("div", {
786
- className: classNames('pro-tree-modal-box', modeType === CASCADER || modeType === LIST && span ? 'pro-tree-modal-cascader-box' : ''),
787
- children: [/*#__PURE__*/_jsx(Input, {
788
- disabled: disabled,
789
- allowClear: true,
790
- value: searchStr,
791
- placeholder: placeholder || locale?.ProTreeModal?.input,
792
- className: "pro-tree-modal-search",
793
- onChange: e => handleSetSearchStr(e.target.value),
794
- prefix: /*#__PURE__*/_jsx(ReactSVG, {
795
- className: "pro-tree-modal-search-svg",
796
- src: searchSVG
797
- })
798
- }), /*#__PURE__*/_jsx("div", {
799
- className: "pro-tree-modal-tree-warp",
800
- children: renderContainer()
801
- })]
802
- }), /*#__PURE__*/_jsxs("div", {
803
- className: classNames('pro-tree-modal-box', modeType === CASCADER || modeType === LIST && span ? 'pro-tree-modal-cascader-box-view' : ''),
804
- children: [/*#__PURE__*/_jsxs("div", {
805
- className: "pro-tree-modal-box-header",
806
- children: [/*#__PURE__*/_jsxs("span", {
807
- children: [locale?.ProTreeModal?.check, " (", checkedValues.length, "/", max || flatTreeData.length, ")"]
808
- }), !isView ? /*#__PURE__*/_jsx(Button, {
809
- disabled: disabled,
810
- type: "link",
811
- onClick: () => handleClearAll(false),
812
- children: locale?.ProTreeModal?.clearAll
813
- }) : null]
814
- }), /*#__PURE__*/_jsx("div", {
815
- className: "pro-tree-modal-tree-warp pro-transfer-right",
816
- children: renderView()
817
- })]
818
- })]
819
- })
820
- })]
821
- })
822
- });
728
+ extraLeft: allValue !== void 0 && !isView ? /* @__PURE__ */ jsx(Checkbox, { checked: checkAll, disabled, onChange: handleAllCheck, children: (_f = (_e = locale) == null ? void 0 : _e.ProTreeModal) == null ? void 0 : _f.checkAll }) : null,
729
+ children: /* @__PURE__ */ jsxs("div", { className: "pro-tree-modal-content", children: [
730
+ /* @__PURE__ */ jsxs(
731
+ "div",
732
+ {
733
+ className: classNames(
734
+ "pro-tree-modal-box",
735
+ modeType === CASCADER || modeType === LIST && span ? "pro-tree-modal-cascader-box" : ""
736
+ ),
737
+ children: [
738
+ /* @__PURE__ */ jsx(
739
+ Input,
740
+ {
741
+ disabled,
742
+ allowClear: true,
743
+ value: searchStr,
744
+ placeholder: placeholder || ((_h = (_g = locale) == null ? void 0 : _g.ProTreeModal) == null ? void 0 : _h.input),
745
+ className: "pro-tree-modal-search",
746
+ onChange: (e) => handleSetSearchStr(e.target.value),
747
+ prefix: /* @__PURE__ */ jsx(ReactSVG, { className: "pro-tree-modal-search-svg", src: searchSVG })
748
+ }
749
+ ),
750
+ /* @__PURE__ */ jsx("div", { className: "pro-tree-modal-tree-warp", children: renderContainer() })
751
+ ]
752
+ }
753
+ ),
754
+ /* @__PURE__ */ jsxs(
755
+ "div",
756
+ {
757
+ className: classNames(
758
+ "pro-tree-modal-box",
759
+ modeType === CASCADER || modeType === LIST && span ? "pro-tree-modal-cascader-box-view" : ""
760
+ ),
761
+ children: [
762
+ /* @__PURE__ */ jsxs("div", { className: "pro-tree-modal-box-header", children: [
763
+ /* @__PURE__ */ jsxs("span", { children: [
764
+ (_j = (_i = locale) == null ? void 0 : _i.ProTreeModal) == null ? void 0 : _j.check,
765
+ " (",
766
+ checkedValues.length,
767
+ "/",
768
+ max || flatTreeData.length,
769
+ ")"
770
+ ] }),
771
+ !isView ? /* @__PURE__ */ jsx(Button, { disabled, type: "link", onClick: () => handleClearAll(false), children: (_l = (_k = locale) == null ? void 0 : _k.ProTreeModal) == null ? void 0 : _l.clearAll }) : null
772
+ ] }),
773
+ /* @__PURE__ */ jsx("div", { className: "pro-tree-modal-tree-warp pro-transfer-right", children: renderView() })
774
+ ]
775
+ }
776
+ )
777
+ ] })
778
+ }
779
+ )
780
+ ] }) });
781
+ };
782
+ var ProTreeModal_default = ProTreeModal;
783
+ export {
784
+ CASCADER,
785
+ ProTreeModal_default as default
823
786
  };
824
- export default ProTreeModal;