@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.
Files changed (280) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/FormsProvider/index.js +14 -21
  4. package/es/ProAction/components/CheckModalContent/index.js +12 -26
  5. package/es/ProAction/index.js +79 -83
  6. package/es/ProAction/propsType.js +0 -1
  7. package/es/ProConfigProvider/index.js +63 -110
  8. package/es/ProConfigProvider/propsType.js +0 -1
  9. package/es/ProDownload/index.d.ts +2 -1
  10. package/es/ProDownload/index.js +74 -69
  11. package/es/ProDownload/propsType.js +0 -1
  12. package/es/ProDownload/utils.d.ts +10 -5
  13. package/es/ProDownload/utils.js +63 -95
  14. package/es/ProDrawerForm/components/ProDrawer/index.js +83 -113
  15. package/es/ProDrawerForm/components/ProModal/index.js +77 -108
  16. package/es/ProDrawerForm/components/index.js +6 -2
  17. package/es/ProDrawerForm/hooks/useConfirmClose.js +20 -39
  18. package/es/ProDrawerForm/index.js +29 -38
  19. package/es/ProDrawerForm/propsType.js +0 -1
  20. package/es/ProDrawerForm/utils/index.js +18 -36
  21. package/es/ProEditLabel/components/RenderProForm.js +45 -49
  22. package/es/ProEditLabel/index.js +126 -163
  23. package/es/ProEditLabel/propsType.js +0 -1
  24. package/es/ProEditLabel/utils/index.js +5 -8
  25. package/es/ProEditTable/components/ActionButton/index.js +111 -119
  26. package/es/ProEditTable/components/RcTable/BaseTable.js +38 -51
  27. package/es/ProEditTable/components/RcTable/DraggableTable.js +97 -129
  28. package/es/ProEditTable/components/RcTable/index.js +6 -4
  29. package/es/ProEditTable/components/RenderField/ListChangedWrapper.js +77 -95
  30. package/es/ProEditTable/components/RenderField/index.js +490 -587
  31. package/es/ProEditTable/components/RenderField/propsType.js +0 -1
  32. package/es/ProEditTable/components/RenderField/tools.js +115 -112
  33. package/es/ProEditTable/components/RenderToolbar/index.js +47 -73
  34. package/es/ProEditTable/components/Summary/index.js +38 -64
  35. package/es/ProEditTable/components/Validator/index.js +46 -46
  36. package/es/ProEditTable/components/index.js +12 -5
  37. package/es/ProEditTable/index.js +456 -378
  38. package/es/ProEditTable/propsType.js +0 -1
  39. package/es/ProEditTable/utils/config.js +60 -122
  40. package/es/ProEditTable/utils/diffOriginal.js +45 -82
  41. package/es/ProEditTable/utils/getDefaultProps.js +19 -24
  42. package/es/ProEditTable/utils/index.js +154 -235
  43. package/es/ProEditTable/utils/tools.js +149 -286
  44. package/es/ProEditTable/utils/transform.js +25 -30
  45. package/es/ProEditTable/utils/useEditTableError.js +30 -43
  46. package/es/ProEditTable/utils/useShouldUpdateForTable.js +42 -72
  47. package/es/ProEditTable/utils/validateAll.js +87 -154
  48. package/es/ProEnum/components/Group.js +38 -30
  49. package/es/ProEnum/components/Tag.js +22 -26
  50. package/es/ProEnum/hooks/useEnum.js +48 -116
  51. package/es/ProEnum/hooks/useEnumRequest.js +182 -212
  52. package/es/ProEnum/hooks/useFrequentEnumRequest.js +40 -48
  53. package/es/ProEnum/index.js +162 -172
  54. package/es/ProEnum/propsType.js +0 -1
  55. package/es/ProEnum/utils/eventCenter.js +10 -12
  56. package/es/ProEnum/utils/frequentEnum.js +35 -92
  57. package/es/ProEnum/utils/getEnum.js +32 -90
  58. package/es/ProEnum/utils/getEnumLabel.js +44 -49
  59. package/es/ProEnum/utils/index.js +93 -207
  60. package/es/ProForm/components/Container.js +13 -28
  61. package/es/ProForm/components/FormFooter/index.js +36 -44
  62. package/es/ProForm/components/FormFooter/propsType.js +0 -1
  63. package/es/ProForm/components/base/Checkbox/index.js +32 -59
  64. package/es/ProForm/components/base/DatePicker/index.js +49 -71
  65. package/es/ProForm/components/base/Input/index.js +63 -97
  66. package/es/ProForm/components/base/Input/propsType.js +0 -1
  67. package/es/ProForm/components/base/InputNumber/index.js +118 -172
  68. package/es/ProForm/components/base/Radio/index.js +39 -52
  69. package/es/ProForm/components/base/RangePicker/index.js +109 -127
  70. package/es/ProForm/components/base/RangePicker/useDateRange.js +20 -17
  71. package/es/ProForm/components/base/Select/index.js +63 -89
  72. package/es/ProForm/components/base/Switch/index.js +27 -35
  73. package/es/ProForm/components/base/SwitchCheckbox/index.js +36 -54
  74. package/es/ProForm/components/base/TextArea/index.js +30 -41
  75. package/es/ProForm/components/base/TimePicker/index.js +27 -37
  76. package/es/ProForm/components/combination/Container/index.js +37 -47
  77. package/es/ProForm/components/combination/Container/propsType.js +0 -1
  78. package/es/ProForm/components/combination/FormList/components/ActionButton.js +165 -237
  79. package/es/ProForm/components/combination/FormList/components/BlockFields.js +98 -102
  80. package/es/ProForm/components/combination/FormList/components/Empty.js +28 -55
  81. package/es/ProForm/components/combination/FormList/components/LineFields.js +57 -54
  82. package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +61 -109
  83. package/es/ProForm/components/combination/FormList/index.js +151 -161
  84. package/es/ProForm/components/combination/FormList/propsType.js +0 -1
  85. package/es/ProForm/components/combination/FormList/style/index.less +6 -0
  86. package/es/ProForm/components/combination/FormList/utils.js +22 -38
  87. package/es/ProForm/components/combination/Group/component/AddonWrapper/index.js +12 -28
  88. package/es/ProForm/components/combination/Group/component/ComRender.js +50 -111
  89. package/es/ProForm/components/combination/Group/component/FlexibleGroup.js +106 -213
  90. package/es/ProForm/components/combination/Group/hooks/index.js +69 -129
  91. package/es/ProForm/components/combination/Group/index.js +87 -126
  92. package/es/ProForm/components/combination/Group/propsType.js +0 -1
  93. package/es/ProForm/components/combination/Group/utils/index.js +124 -239
  94. package/es/ProForm/components/combination/ProCascader/index.js +156 -199
  95. package/es/ProForm/components/combination/ProCascader/propsType.js +0 -1
  96. package/es/ProForm/components/combination/ProCascader/utils/index.js +12 -21
  97. package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +72 -70
  98. package/es/ProForm/components/combination/ProModalSelect/index.js +309 -347
  99. package/es/ProForm/components/combination/ProModalSelect/propsType.js +0 -1
  100. package/es/ProForm/components/combination/ProModalSelect/utils/index.js +32 -39
  101. package/es/ProForm/components/combination/ProNumberRange/index.js +100 -156
  102. package/es/ProForm/components/combination/ProNumberRange/propsType.js +0 -1
  103. package/es/ProForm/components/combination/ProRangeLimit/index.js +104 -115
  104. package/es/ProForm/components/combination/ProRangeLimit/propsType.js +0 -1
  105. package/es/ProForm/components/combination/ProTimeLimit/hooks/useControlled.js +16 -16
  106. package/es/ProForm/components/combination/ProTimeLimit/index.js +75 -109
  107. package/es/ProForm/components/index.js +56 -34
  108. package/es/ProForm/components/render/ChangedWrapper.js +85 -94
  109. package/es/ProForm/components/render/ConfirmWrapper.js +27 -39
  110. package/es/ProForm/components/render/CustomComponentViewWrapper.js +65 -82
  111. package/es/ProForm/components/render/Render.js +223 -329
  112. package/es/ProForm/components/render/RenderFields.js +76 -113
  113. package/es/ProForm/components/render/propsType.js +0 -1
  114. package/es/ProForm/hooks/useControlled.js +8 -10
  115. package/es/ProForm/hooks/useDeepCompareMemo.js +11 -11
  116. package/es/ProForm/hooks/useFieldProps.js +8 -4
  117. package/es/ProForm/hooks/useForm.js +50 -110
  118. package/es/ProForm/hooks/useRules.js +17 -33
  119. package/es/ProForm/hooks/useShouldUpdate.js +77 -152
  120. package/es/ProForm/hooks/useWatch.js +62 -134
  121. package/es/ProForm/index.js +157 -194
  122. package/es/ProForm/propsType.js +15 -7
  123. package/es/ProForm/utils/buildFormItemProps.js +51 -58
  124. package/es/ProForm/utils/diffOriginal.js +43 -73
  125. package/es/ProForm/utils/getDefaultProps.js +18 -24
  126. package/es/ProForm/utils/index.js +160 -235
  127. package/es/ProForm/utils/processDependencies.js +21 -60
  128. package/es/ProForm/utils/reactiveValues.js +20 -34
  129. package/es/ProForm/utils/rulesCreator.js +42 -40
  130. package/es/ProForm/utils/transformNames.js +10 -13
  131. package/es/ProForm/utils/transformValue.js +16 -29
  132. package/es/ProForm/utils/valueType.js +96 -178
  133. package/es/ProIcon/config/index.js +340 -274
  134. package/es/ProIcon/index.js +135 -209
  135. package/es/ProIcon/propsTypes.js +0 -1
  136. package/es/ProIcon/utils/index.js +24 -39
  137. package/es/ProLayout/components/Layout/Header/index.js +108 -141
  138. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +134 -190
  139. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +113 -139
  140. package/es/ProLayout/components/Layout/Menu/OpenMenu/propsType.js +0 -1
  141. package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +23 -31
  142. package/es/ProLayout/components/Layout/Menu/index.js +92 -89
  143. package/es/ProLayout/components/Layout/Notice/index.js +13 -27
  144. package/es/ProLayout/components/Layout/index.js +8 -3
  145. package/es/ProLayout/components/ProCollapse/PropTypes.js +0 -1
  146. package/es/ProLayout/components/ProCollapse/index.js +89 -111
  147. package/es/ProLayout/components/ProFooter/PropTypes.js +0 -1
  148. package/es/ProLayout/components/ProFooter/index.js +27 -24
  149. package/es/ProLayout/components/ProHeader/PropTypes.js +0 -1
  150. package/es/ProLayout/components/ProHeader/components/Copy/index.js +23 -21
  151. package/es/ProLayout/components/ProHeader/components/Describe/index.js +67 -84
  152. package/es/ProLayout/components/ProHeader/components/ProBackBtn/index.js +18 -21
  153. package/es/ProLayout/components/ProHeader/components/ProBackBtn/propsType.js +0 -1
  154. package/es/ProLayout/components/ProHeader/components/index.js +6 -2
  155. package/es/ProLayout/components/ProHeader/index.js +216 -356
  156. package/es/ProLayout/components/ProHeader/utils/index.js +19 -26
  157. package/es/ProLayout/components/TabsManager/components/TabContextMenu.js +92 -85
  158. package/es/ProLayout/components/TabsManager/components/TabItem.js +53 -63
  159. package/es/ProLayout/components/TabsManager/components/TabsContext.js +5 -5
  160. package/es/ProLayout/components/TabsManager/components/TabsHeader.js +42 -52
  161. package/es/ProLayout/components/TabsManager/hooks/useActiveTab.js +8 -9
  162. package/es/ProLayout/components/TabsManager/hooks/useIframeRoute.js +19 -32
  163. package/es/ProLayout/components/TabsManager/hooks/useProLayoutTabs.js +6 -20
  164. package/es/ProLayout/components/TabsManager/hooks/useTabsCache.js +25 -42
  165. package/es/ProLayout/components/TabsManager/hooks/useTabsState.js +320 -350
  166. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.d.ts +19 -0
  167. package/es/ProLayout/components/TabsManager/hooks/useTabsUrlSync.js +332 -0
  168. package/es/ProLayout/components/TabsManager/index.js +407 -351
  169. package/es/ProLayout/components/TabsManager/propTypes.d.ts +4 -0
  170. package/es/ProLayout/components/TabsManager/propTypes.js +7 -15
  171. package/es/ProLayout/components/TabsManager/style/index.less +1 -1
  172. package/es/ProLayout/components/TabsManager/utils/historyObserver.d.ts +7 -0
  173. package/es/ProLayout/components/TabsManager/utils/historyObserver.js +65 -0
  174. package/es/ProLayout/components/TabsManager/utils/index.d.ts +15 -2
  175. package/es/ProLayout/components/TabsManager/utils/index.js +156 -159
  176. package/es/ProLayout/components/index.js +8 -3
  177. package/es/ProLayout/index.js +173 -228
  178. package/es/ProLayout/propTypes.d.ts +28 -1
  179. package/es/ProLayout/propTypes.js +12 -52
  180. package/es/ProLayout/utils/index.js +48 -128
  181. package/es/ProSelect/components/AdaptiveTooltip.js +26 -25
  182. package/es/ProSelect/index.js +187 -223
  183. package/es/ProSelect/propsType.js +0 -1
  184. package/es/ProSelect/style/index.less +13 -0
  185. package/es/ProSelect/utils/index.js +100 -146
  186. package/es/ProStep/components/Anchor/index.js +71 -82
  187. package/es/ProStep/components/Item/index.js +49 -56
  188. package/es/ProStep/components/LazyLoad/index.js +23 -29
  189. package/es/ProStep/components/Listener/index.js +20 -33
  190. package/es/ProStep/components/Step/index.js +31 -38
  191. package/es/ProStep/constants.js +4 -1
  192. package/es/ProStep/index.js +166 -153
  193. package/es/ProStep/propsType.js +0 -1
  194. package/es/ProStep/style/index.less +1 -1
  195. package/es/ProStep/utils/index.js +29 -55
  196. package/es/ProStepTab/index.js +83 -138
  197. package/es/ProStepTab/propsType.js +0 -1
  198. package/es/ProTable/components/EditableCell/EditIcon.js +10 -14
  199. package/es/ProTable/components/EditableCell/index.js +37 -71
  200. package/es/ProTable/components/EditableCell/propsType.js +0 -1
  201. package/es/ProTable/components/FormatColumn/index.js +209 -340
  202. package/es/ProTable/components/FormatColumn/propsType.js +0 -1
  203. package/es/ProTable/components/RcTable/components/BaseTable/index.js +35 -39
  204. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +80 -107
  205. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/index.js +54 -48
  206. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/utils/propsType.js +0 -1
  207. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +47 -54
  208. package/es/ProTable/components/RcTable/index.js +6 -4
  209. package/es/ProTable/components/RenderColumn/index.js +158 -186
  210. package/es/ProTable/components/RenderEmptyText/index.js +12 -21
  211. package/es/ProTable/components/RenderFooter/index.js +15 -15
  212. package/es/ProTable/components/RenderSummary/index.js +33 -50
  213. package/es/ProTable/components/RenderTableHeader/index.js +44 -46
  214. package/es/ProTable/components/RenderTabs/index.js +47 -51
  215. package/es/ProTable/components/TableResizable/index.js +56 -72
  216. package/es/ProTable/components/TooltipTitle/index.js +13 -21
  217. package/es/ProTable/components/index.js +16 -36
  218. package/es/ProTable/hooks/useAntdTable.js +191 -224
  219. package/es/ProTable/index.js +232 -249
  220. package/es/ProTable/propsType.js +0 -1
  221. package/es/ProTable/utils/columnStorage.js +63 -88
  222. package/es/ProTable/utils/index.js +57 -90
  223. package/es/ProTabs/components/Card/index.js +20 -48
  224. package/es/ProTabs/components/index.js +4 -1
  225. package/es/ProTabs/index.js +41 -58
  226. package/es/ProTabs/propType.js +0 -1
  227. package/es/ProThemeTools/component/ProTools/index.js +106 -158
  228. package/es/ProThemeTools/component/index.js +4 -1
  229. package/es/ProThemeTools/context/ThemeContext.js +67 -146
  230. package/es/ProThemeTools/index.js +103 -156
  231. package/es/ProThemeTools/propsType.js +0 -1
  232. package/es/ProThemeTools/utils/index.js +60 -109
  233. package/es/ProTooltip/index.js +132 -168
  234. package/es/ProTooltip/propsType.js +0 -1
  235. package/es/ProTree/components/AdaptiveTooltip.js +15 -17
  236. package/es/ProTree/components/CloseIcon.js +18 -26
  237. package/es/ProTree/components/List.js +28 -47
  238. package/es/ProTree/components/ProTree.js +152 -211
  239. package/es/ProTree/components/ProTreeSelect/index.js +255 -459
  240. package/es/ProTree/components/ProTreeSelect/propsType.js +0 -1
  241. package/es/ProTree/components/SearchTitle.js +23 -42
  242. package/es/ProTree/components/Tree.js +147 -195
  243. package/es/ProTree/components/index.js +10 -5
  244. package/es/ProTree/index.js +12 -16
  245. package/es/ProTree/propsType.js +0 -1
  246. package/es/ProTree/utils.js +46 -118
  247. package/es/ProTreeModal/components/Cascader.js +56 -64
  248. package/es/ProTreeModal/components/CloseIcon.js +18 -26
  249. package/es/ProTreeModal/components/List.js +114 -180
  250. package/es/ProTreeModal/components/SearchTitle.js +15 -18
  251. package/es/ProTreeModal/components/SortableItem.js +29 -58
  252. package/es/ProTreeModal/components/Tree.js +99 -113
  253. package/es/ProTreeModal/components/Trigger.js +87 -121
  254. package/es/ProTreeModal/components/index.js +14 -6
  255. package/es/ProTreeModal/index.js +397 -438
  256. package/es/ProTreeModal/propsType.js +0 -1
  257. package/es/ProTreeModal/utils.js +52 -95
  258. package/es/ProUpload/components/ButtonRender.js +44 -54
  259. package/es/ProUpload/components/DragRender.js +94 -148
  260. package/es/ProUpload/components/DraggableUploadListItem.js +12 -25
  261. package/es/ProUpload/components/Example.js +27 -31
  262. package/es/ProUpload/components/FileItem.js +69 -163
  263. package/es/ProUpload/components/ImageRender.js +134 -170
  264. package/es/ProUpload/index.js +68 -100
  265. package/es/ProUpload/propsType.js +0 -1
  266. package/es/ProUpload/uitls.js +8 -4
  267. package/es/ProUtils/utils/index.js +17 -13
  268. package/es/ProViewer/index.js +154 -175
  269. package/es/ProViewer/propsType.js +0 -5
  270. package/es/ProWaterMark/index.js +9 -16
  271. package/es/ProWaterMark/propsType.js +0 -1
  272. package/es/hooks/useDraggableRow.js +25 -53
  273. package/es/index.js +57 -77
  274. package/es/locale/en_US.js +153 -142
  275. package/es/locale/index.js +23 -36
  276. package/es/locale/zh_CN.js +145 -142
  277. package/es/tokens.js +84 -83
  278. package/es/utils/index.js +24 -51
  279. package/package.json +4 -2
  280. package/es/ProConfigProvider/demo/locale.js +0 -58
@@ -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,112 +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
- if (appoint) {
568
- openChange?.(true);
569
- }
570
524
  }
571
525
  };
572
-
573
- /**
574
- * Trigger the container opened by Drawer
575
- * default example and you can customize trigger={<Button>打开</Button>}
576
- * @returns
577
- */
578
526
  const TriggerComponent = useMemo(() => {
579
- if (trigger && /*#__PURE__*/React.isValidElement(trigger)) {
580
- return /*#__PURE__*/_jsx("div", {
581
- onClick: handleClick,
582
- children: trigger
583
- });
527
+ var _a2;
528
+ if (trigger && React.isValidElement(trigger)) {
529
+ return /* @__PURE__ */ jsx("div", { onClick: handleClick, children: trigger });
584
530
  }
585
- return /*#__PURE__*/_jsx(Trigger, {
586
- checkedValues: checkedValues,
587
- value: value,
588
- checkAll: checkAll,
589
- triggerStyle: style,
590
- disabled: disabled,
591
- isView: isView,
592
- appoint: appoint,
593
- allValue: allValue,
594
- label: props?.otherProps?.label,
595
- handleClick: handleClick,
596
- handleClearAll: () => handleClearAll(true),
597
- appointChange: appointChange,
598
- appointProps: appointProps
599
- });
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
+ );
600
549
  }, [checkedValues, checkAll, style, disabled, isView, value]);
601
-
602
- /**
603
- * 全选操作
604
- */
605
- const handleAllCheck = e => {
606
- const {
607
- checked
608
- } = e.target;
550
+ const handleAllCheck = (e) => {
551
+ var _a2, _b2;
552
+ const { checked } = e.target;
609
553
  let nextCheckedValues = [];
610
554
  let nextTreeViewData = [];
611
555
  if (checked) {
612
- 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]);
613
557
  } else if (modeType === LIST || modeType === CASCADER) {
614
558
  if (span) {
615
- // ProTable 场景下 disabled 不取消掉
616
- nextCheckedValues = flatTreeData.filter(item => item.disabled).map(item => item[fieldNameValue]);
559
+ nextCheckedValues = flatTreeData.filter((item) => item.disabled).map((item) => item[fieldNameValue]);
617
560
  } else {
618
561
  nextCheckedValues = [];
619
562
  }
620
563
  }
621
564
  if (modeType === TREE) {
622
565
  if (checkStrictly) {
623
- nextTreeViewData = flatTreeData.filter(item => nextCheckedValues.includes(item[fieldNameValue]));
566
+ nextTreeViewData = flatTreeData.filter(
567
+ (item) => nextCheckedValues.includes(item[fieldNameValue])
568
+ );
624
569
  } else {
625
- nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, '', fieldNames);
570
+ nextTreeViewData = filterCheckedNodes(originalTreeData, nextCheckedValues, "", fieldNames);
626
571
  }
627
572
  }
628
573
  if (max && nextCheckedValues.length > max) {
629
- message.error(maxMessage ? transformMessage({
630
- max
631
- }, maxMessage) : formatMessage(locale?.ProTreeModal?.selectMax, {
632
- max
633
- }));
574
+ message.error(
575
+ maxMessage ? transformMessage({ max }, maxMessage) : formatMessage((_b2 = (_a2 = locale) == null ? void 0 : _a2.ProTreeModal) == null ? void 0 : _b2.selectMax, { max })
576
+ );
634
577
  return;
635
578
  }
636
579
  setState({
@@ -639,189 +582,205 @@ const ProTreeModal = props => {
639
582
  treeViewData: nextTreeViewData
640
583
  });
641
584
  };
642
-
643
- /**
644
- * 左侧容器、分为三种 list、tree、Cascader
645
- * @returns
646
- */
647
585
  const renderContainer = () => {
586
+ var _a2, _b2;
648
587
  if (treeData.length === 0 && searchStr) {
649
- return /*#__PURE__*/_jsx("div", {
650
- className: "pro-tree-modal-no-checks",
651
- children: locale?.ProTreeModal?.noFinal
652
- });
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 });
653
589
  }
654
590
  switch (modeType) {
655
591
  case LIST:
656
- return /*#__PURE__*/_jsx(ListView, {
657
- treeData: treeData,
658
- optionRender: optionRender,
659
- checkedValues: checkedValues,
660
- handleOnChange: handleListCheckChange,
661
- searchStr: searchStr,
662
- showCodeName: showCodeName,
663
- disabled: disabled || isView,
664
- fieldNames: fieldNames,
665
- span: span
666
- });
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
+ );
667
606
  case TREE:
668
- return /*#__PURE__*/_jsx(TreeView, {
669
- treeData: transformedTree,
670
- originalTreeData: originalTreeData,
671
- flatTreeData: flatTreeData,
672
- checkedValues: checkedValues,
673
- onCheck: onCheck,
674
- optionRender: optionRender,
675
- searchStr: searchStr,
676
- showCodeName: showCodeName,
677
- disabled: disabled || isView,
678
- checkStrictly: checkStrictly,
679
- tags: tags,
680
- fieldNames: fieldNames
681
- });
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
+ );
682
624
  case CASCADER:
683
625
  if (searchStr && treeData.length) {
684
- return /*#__PURE__*/_jsx(ListView, {
685
- treeData: treeData,
686
- modeType: CASCADER,
687
- optionRender: optionRender,
688
- checkedValues: checkedValues,
689
- handleOnChange: handleListCheckChange,
690
- searchStr: searchStr,
691
- showCodeName: showCodeName,
692
- disabled: disabled || isView,
693
- fieldNames: fieldNames
694
- });
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
+ );
695
640
  }
696
- return /*#__PURE__*/_jsx(Cascader, {
697
- dataSource: treeData,
698
- fieldNames: fieldNames,
699
- checkedValues: checkedValues,
700
- searchStr: searchStr,
701
- showCodeName: showCodeName,
702
- handleOnChange: handleListCheckChange,
703
- optionRender: optionRender
704
- });
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
+ );
705
653
  default:
706
654
  break;
707
655
  }
708
656
  };
709
657
  const listTreeData = useMemo(() => {
710
658
  const checkListOptions = [];
711
- checkedValues.forEach(key => {
712
- const option = flatTreeData.find(item => item[fieldNameValue] === key);
659
+ checkedValues.forEach((key) => {
660
+ const option = flatTreeData.find((item) => item[fieldNameValue] === key);
713
661
  if (option) {
714
662
  checkListOptions.push(option);
715
663
  }
716
664
  });
717
665
  return checkListOptions;
718
666
  }, [checkedValues, flatTreeData]);
719
-
720
- /**
721
- * 勾选后的右侧展示
722
- * @returns
723
- */
724
667
  const renderView = () => {
668
+ var _a2, _b2;
725
669
  if (checkedValues.length === 0) {
726
- return /*#__PURE__*/_jsx("div", {
727
- className: "pro-tree-modal-no-checks",
728
- children: locale?.ProTreeModal?.noCheck
729
- });
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 });
730
671
  }
731
672
  switch (modeType) {
732
673
  case LIST:
733
674
  case CASCADER:
734
- return /*#__PURE__*/_jsx(ListView, {
735
- mode: "view",
736
- showCodeName: showCodeName,
737
- treeData: listTreeData,
738
- fieldNames: fieldNames,
739
- disabled: disabled || isView,
740
- draggable: draggable,
741
- flatTreeData: flatTreeData,
742
- span: span,
743
- ref: listRef,
744
- optionRender: optionRender,
745
- handleFilterClose: handleFilterClose,
746
- handleDragEndChange: handleDragEndChange
747
- });
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
+ );
748
692
  case TREE:
749
- return /*#__PURE__*/_jsx(TreeView, {
750
- mode: "view",
751
- checkStrictly: checkStrictly,
752
- showCodeName: showCodeName,
753
- treeData: checkStrictly ? listTreeData : treeViewData,
754
- tags: tags,
755
- fieldNames: fieldNames,
756
- disabled: disabled || isView,
757
- draggable: draggable,
758
- min: min,
759
- max: max,
760
- ref: listRef,
761
- handleFilterClose: treeFilterClose,
762
- optionRender: optionRender,
763
- handleDragEndChange: handleDragEndChange
764
- });
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
+ );
765
712
  default:
766
713
  break;
767
714
  }
768
715
  };
769
- return /*#__PURE__*/_jsx(_Fragment, {
770
- children: /*#__PURE__*/_jsxs("div", {
771
- className: "pro-tree-modal",
772
- 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
+ {
773
721
  onOk: handleFinish,
774
722
  onCancel: handleClose,
775
723
  okDisabled: disabled,
776
- open: open,
777
- title: title,
724
+ open,
725
+ title,
778
726
  mode: "Modal",
779
727
  className: "pro-tree-modal-container",
780
- extraLeft: allValue !== undefined && !isView ? /*#__PURE__*/_jsx(Checkbox, {
781
- checked: checkAll,
782
- disabled: disabled,
783
- onChange: handleAllCheck,
784
- children: locale?.ProTreeModal?.checkAll
785
- }) : null,
786
- children: /*#__PURE__*/_jsxs("div", {
787
- className: "pro-tree-modal-content",
788
- children: [/*#__PURE__*/_jsxs("div", {
789
- className: classNames('pro-tree-modal-box', modeType === CASCADER || modeType === LIST && span ? 'pro-tree-modal-cascader-box' : ''),
790
- children: [/*#__PURE__*/_jsx(Input, {
791
- disabled: disabled,
792
- allowClear: true,
793
- value: searchStr,
794
- placeholder: placeholder || locale?.ProTreeModal?.input,
795
- className: "pro-tree-modal-search",
796
- onChange: e => handleSetSearchStr(e.target.value),
797
- prefix: /*#__PURE__*/_jsx(ReactSVG, {
798
- className: "pro-tree-modal-search-svg",
799
- src: searchSVG
800
- })
801
- }), /*#__PURE__*/_jsx("div", {
802
- className: "pro-tree-modal-tree-warp",
803
- children: renderContainer()
804
- })]
805
- }), /*#__PURE__*/_jsxs("div", {
806
- className: classNames('pro-tree-modal-box', modeType === CASCADER || modeType === LIST && span ? 'pro-tree-modal-cascader-box-view' : ''),
807
- children: [/*#__PURE__*/_jsxs("div", {
808
- className: "pro-tree-modal-box-header",
809
- children: [/*#__PURE__*/_jsxs("span", {
810
- children: [locale?.ProTreeModal?.check, " (", checkedValues.length, "/", max || flatTreeData.length, ")"]
811
- }), !isView ? /*#__PURE__*/_jsx(Button, {
812
- disabled: disabled,
813
- type: "link",
814
- onClick: () => handleClearAll(false),
815
- children: locale?.ProTreeModal?.clearAll
816
- }) : null]
817
- }), /*#__PURE__*/_jsx("div", {
818
- className: "pro-tree-modal-tree-warp pro-transfer-right",
819
- children: renderView()
820
- })]
821
- })]
822
- })
823
- })]
824
- })
825
- });
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
826
786
  };
827
- export default ProTreeModal;