@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,15 +1,22 @@
1
- import _isObject from "lodash/isObject";
2
- import _isFunction from "lodash/isFunction";
3
- import _isEqual from "lodash/isEqual";
4
- import _isBoolean from "lodash/isBoolean";
5
- import _isArray from "lodash/isArray";
6
- import _debounce from "lodash/debounce";
7
- import { SearchOutlined } from '@ant-design/icons';
8
- import { useDebounceEffect, useDeepCompareEffect, useMount, useSetState } from 'ahooks';
9
- import { Form, message, Input, Tooltip, Space, Button, Spin } from 'antd';
10
- import classNames from 'classnames';
11
- import { ReactSVG } from 'react-svg';
12
- import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { SearchOutlined } from "@ant-design/icons";
3
+ import { useDebounceEffect, useDeepCompareEffect, useMount, useSetState } from "ahooks";
4
+ import { Form, message, Input, Tooltip, Space, Button, Spin } from "antd";
5
+ import debounce from "lodash/debounce";
6
+ import isArray from "lodash/isArray";
7
+ import isBoolean from "lodash/isBoolean";
8
+ import isEqual from "lodash/isEqual";
9
+ import isFunction from "lodash/isFunction";
10
+ import isObject from "lodash/isObject";
11
+ import classNames from "classnames";
12
+ import { ReactSVG } from "react-svg";
13
+ import React, {
14
+ forwardRef,
15
+ useEffect,
16
+ useImperativeHandle,
17
+ useMemo,
18
+ useRef
19
+ } from "react";
13
20
  import { ProForm, ProDrawerForm, ProTable, useProConfig, ProSelect } from "../../../../index";
14
21
  import Container from "../../Container";
15
22
  import viewSvg from "../../../../assets/view.svg";
@@ -17,8 +24,8 @@ import useRequestList from "./hooks/useRequestList";
17
24
  import locale from "../../../../locale";
18
25
  import { hideTooltipIfOpen, mergeSelectedRows } from "./utils";
19
26
  import { generateId } from "../../../../utils";
20
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
21
27
  const ProModalSelect = (props, ref) => {
28
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
22
29
  const {
23
30
  value,
24
31
  onChange,
@@ -26,7 +33,7 @@ const ProModalSelect = (props, ref) => {
26
33
  labelInValue = false,
27
34
  fieldNames,
28
35
  readOnly = true,
29
- mode = 'select',
36
+ mode = "select",
30
37
  addonAfter,
31
38
  configOption,
32
39
  title,
@@ -48,17 +55,17 @@ const ProModalSelect = (props, ref) => {
48
55
  } = props;
49
56
  const _tooltip = tooltip ?? isTooltip;
50
57
  const nextMode = useMemo(() => {
51
- if (_isBoolean(readOnly) && readOnly === false) {
52
- return 'input';
58
+ if (isBoolean(readOnly) && readOnly === false) {
59
+ return "input";
53
60
  }
54
61
  return mode;
55
62
  }, [mode, readOnly]);
56
63
  const contentForm = Form.useFormInstance();
57
- if (!configOption || Object.prototype.toString.call(configOption) !== '[object Object]') {
58
- throw new Error('error: 请检查枚举选择弹框的配置项【configOption】');
64
+ if (!configOption || Object.prototype.toString.call(configOption) !== "[object Object]") {
65
+ throw new Error("error: 请检查枚举选择弹框的配置项【configOption】");
59
66
  }
60
67
  const {
61
- type = 'radio',
68
+ type = "radio",
62
69
  useRequest,
63
70
  transformParams,
64
71
  transformResponse,
@@ -67,150 +74,124 @@ const ProModalSelect = (props, ref) => {
67
74
  modalProps,
68
75
  tableProps
69
76
  } = configOption;
70
- const {
71
- onOk,
72
- ...restModalProps
73
- } = modalProps || {};
74
- const {
75
- isView: isViewCon,
76
- viewEmpty
77
- } = ProForm.useFieldProps() || {};
78
- const isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
79
-
80
- // 是否多选
81
- const isMultiple = type === 'checkbox';
82
-
83
- // 生成一个唯一id,用于满足tooltip功能
77
+ const { onOk, ...restModalProps } = modalProps || {};
78
+ const { isView: isViewCon, viewEmpty } = ProForm.useFieldProps() || {};
79
+ const isView = typeof props.isView === "boolean" ? props.isView : isViewCon;
80
+ const isMultiple = type === "checkbox";
84
81
  const uuid = generateId();
85
-
86
- // 全局配置fieldNames指定 value与label的key
87
- const {
88
- fieldNames: proModalSelectFieldNames = {}
89
- } = useProConfig('ProModalSelect') || {};
90
- let labelKey = 'label';
91
- let valueKey = 'value';
82
+ const { fieldNames: proModalSelectFieldNames = {} } = useProConfig("ProModalSelect") || {};
83
+ let labelKey = "label";
84
+ let valueKey = "value";
92
85
  if (proModalSelectFieldNames && Object.keys(proModalSelectFieldNames).length) {
93
86
  labelKey = proModalSelectFieldNames.label;
94
87
  valueKey = proModalSelectFieldNames.value;
95
88
  }
96
-
97
- // 表单上配置的权重大于全局配置
98
89
  if (fieldNames && Object.keys(fieldNames).length) {
99
90
  labelKey = fieldNames.label;
100
91
  valueKey = fieldNames.value;
101
92
  }
102
- const {
103
- rowKey = valueKey,
104
- columns,
105
- rowSelection,
106
- ...restTableProps
107
- } = tableProps || {};
93
+ const { rowKey = valueKey, columns, rowSelection, ...restTableProps } = tableProps || {};
108
94
  const preValue = useRef(value);
109
- // 表单项的ref
110
95
  const fieldRef = useRef(null);
111
- const defaultParams = Array.isArray(useRequest?.options?.defaultParams) ? useRequest?.options?.defaultParams?.[0] : useRequest?.options?.defaultParams || {};
112
- const defaultParamsRef = useRef(defaultParams); // 缓存 defaultParams 的引用
113
-
114
- const [{
115
- _value,
116
- isInit,
117
- onOff,
118
- open,
119
- options,
120
- selectedRows: _selectedRows,
121
- selectedRowKeys: _selectedRowKeys
122
- }, setState] = useSetState({
96
+ const defaultParams = Array.isArray((_a = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a.defaultParams) ? (_c = (_b = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _b.defaultParams) == null ? void 0 : _c[0] : ((_d = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _d.defaultParams) || {};
97
+ const defaultParamsRef = useRef(defaultParams);
98
+ const [
99
+ {
100
+ _value,
101
+ isInit,
102
+ onOff,
103
+ open,
104
+ options,
105
+ selectedRows: _selectedRows,
106
+ selectedRowKeys: _selectedRowKeys
107
+ },
108
+ setState
109
+ ] = useSetState({
123
110
  _value: value,
124
111
  isInit: true,
125
112
  onOff: false,
126
113
  open: false,
127
- options: tableProps?.dataSource || [],
114
+ options: (tableProps == null ? void 0 : tableProps.dataSource) || [],
128
115
  selectedRows: [],
129
116
  selectedRowKeys: []
130
117
  });
131
118
  const [form] = Form.useForm(searchForm);
132
- const selectedRows = rowSelection?.selectedRows || _selectedRows;
133
- const selectedRowKeys = rowSelection?.selectedRowKeys || _selectedRowKeys;
134
- const {
135
- run,
136
- loading: selectLoading
137
- } = useRequestList(useRequest?.service, {
138
- withPagination,
139
- transformParams,
140
- transformResponse
141
- }, {
142
- ...useRequest?.options,
143
- manual: true,
144
- onSuccess(res) {
145
- const list = withPagination ? res?.data?.list : res?.data;
146
- setState({
147
- options: (transformResponse ? transformResponse(res?.data) : list) ?? []
148
- });
119
+ const selectedRows = (rowSelection == null ? void 0 : rowSelection.selectedRows) || _selectedRows;
120
+ const selectedRowKeys = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || _selectedRowKeys;
121
+ const { run, loading: selectLoading } = useRequestList(
122
+ useRequest == null ? void 0 : useRequest.service,
123
+ {
124
+ withPagination,
125
+ transformParams,
126
+ transformResponse
127
+ },
128
+ {
129
+ ...useRequest == null ? void 0 : useRequest.options,
130
+ manual: true,
131
+ onSuccess(res) {
132
+ var _a2;
133
+ const list = withPagination ? (_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.list : res == null ? void 0 : res.data;
134
+ setState({
135
+ options: (transformResponse ? transformResponse(res == null ? void 0 : res.data) : list) ?? []
136
+ });
137
+ }
149
138
  }
150
- });
139
+ );
151
140
  const initParams = useMemo(() => {
152
- let nextInitParams = useRequest?.initParams;
153
- if (typeof useRequest?.initParams === 'function') {
154
- nextInitParams = useRequest?.initParams(value, contentForm?.getFieldsValue?.());
141
+ var _a2;
142
+ let nextInitParams = useRequest == null ? void 0 : useRequest.initParams;
143
+ if (typeof (useRequest == null ? void 0 : useRequest.initParams) === "function") {
144
+ nextInitParams = useRequest == null ? void 0 : useRequest.initParams(value, (_a2 = contentForm == null ? void 0 : contentForm.getFieldsValue) == null ? void 0 : _a2.call(contentForm));
155
145
  }
156
146
  return nextInitParams;
157
147
  }, [value]);
158
- const {
159
- data,
160
- loading,
161
- pagination,
162
- onSearch,
163
- onReset,
164
- runAsync,
165
- mutate
166
- } = useRequestList(useRequest?.service, {
167
- withPagination,
168
- transformParams,
169
- transformResponse
170
- }, {
171
- ready: (initParams || defaultOne) && nextMode === 'input' || open,
172
- ...useRequest?.options
173
- });
174
- const defaultOptionRender = rowData => rowData?.[labelKey];
148
+ const { data, loading, pagination, onSearch, onReset, runAsync, mutate } = useRequestList(
149
+ useRequest == null ? void 0 : useRequest.service,
150
+ {
151
+ withPagination,
152
+ transformParams,
153
+ transformResponse
154
+ },
155
+ {
156
+ ...useRequest == null ? void 0 : useRequest.options,
157
+ ready: ((_e = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _e.ready) ?? ((initParams || defaultOne) && nextMode === "input" ? true : void 0),
158
+ manual: ((_f = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _f.manual) ?? ((initParams || defaultOne) && nextMode === "input" ? void 0 : true)
159
+ }
160
+ );
161
+ const defaultOptionRender = (rowData) => rowData == null ? void 0 : rowData[labelKey];
175
162
  let handleFormat = onFormat || defaultOptionRender;
176
163
  if (showCodeName) {
177
- handleFormat = ({
178
- value,
179
- label
180
- }) => `${value}-${label}`;
164
+ handleFormat = ({ value: value2, label }) => `${value2}-${label}`;
181
165
  }
182
-
183
- /**
184
- * 格式化数据方法,展示在输入框中
185
- * @date 2023-02-16
186
- * @param {any} data 当前选中的值 labelInValue模式下为选中行对象,单值模式为value值
187
- * @returns {any}
188
- */
189
- const formatValue = data => {
190
- if (typeof data === 'string' || typeof data === 'number') {
191
- return data;
166
+ const formatValue = (data2) => {
167
+ if (typeof data2 === "string" || typeof data2 === "number") {
168
+ return data2;
192
169
  }
193
- if (_isObject(data)) {
194
- return handleFormat({
195
- ...data,
196
- value: data[valueKey],
197
- label: data[labelKey]
198
- });
170
+ if (isArray(data2)) {
171
+ return data2.map((item) => {
172
+ return handleFormat({
173
+ ...item,
174
+ value: item[valueKey],
175
+ label: item[labelKey]
176
+ });
177
+ }).join("、");
199
178
  }
200
- return _isArray(data) ? data?.map(item => {
179
+ if (isObject(data2)) {
201
180
  return handleFormat({
202
- ...item,
203
- value: item[valueKey],
204
- label: item[labelKey]
181
+ ...data2,
182
+ value: data2[valueKey],
183
+ label: data2[labelKey]
205
184
  });
206
- })?.join('、') : '';
185
+ }
186
+ return "";
207
187
  };
208
188
  const viewText = useMemo(() => {
189
+ var _a2;
209
190
  let nextValue = labelInValue ? value : _value;
210
191
  if (labelInValue) {
211
192
  nextValue = value;
212
193
  } else {
213
- const optionDTO = options?.find?.(item => item[valueKey] === value);
194
+ const optionDTO = (_a2 = options == null ? void 0 : options.find) == null ? void 0 : _a2.call(options, (item) => item[valueKey] === value);
214
195
  if (optionDTO) {
215
196
  nextValue = optionDTO;
216
197
  } else {
@@ -219,36 +200,22 @@ const ProModalSelect = (props, ref) => {
219
200
  }
220
201
  return formatValue(nextValue);
221
202
  }, [value, _value, options]);
222
-
223
- /**
224
- * 获取表格的rowKey,支持函数、字符串
225
- * @date 2023-02-16
226
- * @param {any} record 表格行数据
227
- * @returns {any}
228
- */
229
- const getRowKey = record => {
230
- if (_isFunction(rowKey)) {
203
+ const getRowKey = (record) => {
204
+ if (isFunction(rowKey)) {
231
205
  return rowKey(record);
232
206
  }
233
207
  return record[rowKey];
234
208
  };
235
-
236
- /**
237
- * 执行onChange暴露出来的第一个参数取数方法
238
- * @date 2023-02-16
239
- * @param {any} selectedRows 选中行数据
240
- * @returns {any}
241
- */
242
- const getNextValues = selectedRows => {
209
+ const getNextValues = (selectedRows2) => {
243
210
  if (isMultiple) {
244
- return selectedRows.map(item => item?.[valueKey]);
211
+ return selectedRows2.map((item) => item == null ? void 0 : item[valueKey]);
245
212
  }
246
- return selectedRows?.[valueKey];
213
+ return selectedRows2 == null ? void 0 : selectedRows2[valueKey];
247
214
  };
248
- const handleChangeValue = e => {
215
+ const handleChangeValue = (e) => {
249
216
  onChange(e.target.value);
250
217
  preValue.current = e.target.value;
251
- if (nextMode === 'input') {
218
+ if (nextMode === "input") {
252
219
  setState({
253
220
  _value: e.target.value
254
221
  });
@@ -260,13 +227,13 @@ const ProModalSelect = (props, ref) => {
260
227
  };
261
228
  const handleClick = async () => {
262
229
  if (!disabled) {
263
- const res = (await beforeOpen?.()) ?? true;
230
+ const res = await (beforeOpen == null ? void 0 : beforeOpen()) ?? true;
264
231
  if (res) {
265
232
  setState({
266
233
  onOff: true
267
234
  });
268
235
  setTimeout(() => {
269
- afterOpen?.({
236
+ afterOpen == null ? void 0 : afterOpen({
270
237
  setInnerState: setState
271
238
  });
272
239
  }, 100);
@@ -274,57 +241,51 @@ const ProModalSelect = (props, ref) => {
274
241
  }
275
242
  };
276
243
  const handleClose = () => {
244
+ var _a2;
277
245
  form.resetFields();
278
246
  setState({
279
247
  onOff: false,
280
248
  open: false,
281
249
  isInit: false
282
250
  });
283
-
284
- // 当设置manual为true时,清空当前弹框内已搜索出来的值
285
- if (useRequest?.options?.manual) {
251
+ if ((_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.manual) {
286
252
  mutate(() => []);
287
253
  }
288
254
  };
289
255
  const handleFinish = async () => {
290
256
  try {
291
- if (!selectedRowKeys?.length || !selectedRows?.length) {
257
+ if (!(selectedRowKeys == null ? void 0 : selectedRowKeys.length) || !(selectedRows == null ? void 0 : selectedRows.length)) {
292
258
  message.error(locale.ProModalSelect.checkMsg);
293
259
  return false;
294
260
  }
295
261
  let nextSelectedRows = selectedRows;
296
- if (!nextSelectedRows?.[0]) {
297
- nextSelectedRows = data.filter(item => selectedRowKeys.includes(item[valueKey]));
262
+ if (!(nextSelectedRows == null ? void 0 : nextSelectedRows[0])) {
263
+ nextSelectedRows = data.filter((item) => selectedRowKeys.includes(item[valueKey]));
298
264
  }
299
- const record = isMultiple ? nextSelectedRows : nextSelectedRows?.[0];
265
+ const record = isMultiple ? nextSelectedRows : nextSelectedRows == null ? void 0 : nextSelectedRows[0];
300
266
  if (!isMultiple) {
301
- // @ts-ignore
302
267
  record.value = record[valueKey];
303
- // @ts-ignore
304
268
  record.label = record[labelKey];
305
269
  }
306
270
  let flag = true;
307
271
  if (onOk) {
308
- // @ts-ignore
309
272
  const res = await onOk(record);
310
- if (res !== null && res !== undefined) {
311
- // @ts-ignore
273
+ if (res !== null && res !== void 0) {
312
274
  flag = res;
313
275
  }
314
276
  }
315
277
  if (flag) {
316
- onChange?.(labelInValue ? record : getNextValues(record), record);
278
+ onChange == null ? void 0 : onChange(labelInValue ? record : getNextValues(record), record);
317
279
  preValue.current = labelInValue ? record : getNextValues(record);
318
- // 更新内部展示值
319
280
  setState({
320
281
  _value: record,
321
- options: _isArray(record) ? record : [record]
282
+ options: isArray(record) ? record : [record]
322
283
  });
323
284
  handleClose();
324
285
  }
325
286
  return flag;
326
287
  } catch (error) {
327
- console.warn('error', error);
288
+ console.warn("error", error);
328
289
  }
329
290
  };
330
291
  const handleSearch = async () => {
@@ -334,38 +295,49 @@ const ProModalSelect = (props, ref) => {
334
295
  d: Date.now()
335
296
  });
336
297
  };
298
+ const handleReset = () => {
299
+ form.resetFields();
300
+ formColumns == null ? void 0 : formColumns.forEach((column) => {
301
+ if ((column == null ? void 0 : column.name) !== void 0 && Object.prototype.hasOwnProperty.call(column, "initialValue")) {
302
+ form.setFieldValue(column.name, column.initialValue);
303
+ }
304
+ });
305
+ onSearch({
306
+ ...form.getFieldsValue(),
307
+ d: Date.now()
308
+ });
309
+ };
337
310
  const _rowSelection = {
338
311
  type,
339
312
  // 多选时开启,保证翻页/筛选后不丢弃不在当前页的已选 key
340
313
  preserveSelectedRowKeys: isMultiple,
341
314
  onChange: (rowKeys, rows) => {
342
- // 多选时合并跨页已选行:antd 回传的 rows 中不在当前页的为 undefined,用历史 selectedRows 补全
343
315
  const nextSelectedRows = isMultiple ? mergeSelectedRows(selectedRows, rowKeys, rows, getRowKey) : rows;
344
316
  setState({
345
317
  selectedRowKeys: rowKeys,
346
318
  selectedRows: nextSelectedRows
347
319
  });
348
320
  },
349
- getCheckboxProps: record => ({
350
- disabled: record?.disabled
321
+ getCheckboxProps: (record) => ({
322
+ disabled: record == null ? void 0 : record.disabled
351
323
  }),
352
324
  selectedRowKeys,
353
325
  selectedRows,
354
326
  ...rowSelection
355
327
  };
356
-
357
- // 点击行进行勾选
358
- const handleClickRow = record => {
359
- if (_rowSelection?.getCheckboxProps?.(record)?.disabled) {
328
+ const handleClickRow = (record) => {
329
+ var _a2, _b2;
330
+ if ((_b2 = (_a2 = _rowSelection == null ? void 0 : _rowSelection.getCheckboxProps) == null ? void 0 : _a2.call(_rowSelection, record)) == null ? void 0 : _b2.disabled) {
360
331
  return;
361
332
  }
362
- if (record?.disabled) return;
333
+ if (record == null ? void 0 : record.disabled)
334
+ return;
363
335
  const selectedValue = getRowKey(record);
364
336
  let tempSelectedRows = [...selectedRows];
365
337
  let tempSelectedRowKeys = [...selectedRowKeys];
366
338
  if (isMultiple) {
367
- const rowIndex = tempSelectedRows.findIndex(item => getRowKey(item) === selectedValue);
368
- const rowKeyIndex = tempSelectedRowKeys.findIndex(item => item === selectedValue);
339
+ const rowIndex = tempSelectedRows.findIndex((item) => getRowKey(item) === selectedValue);
340
+ const rowKeyIndex = tempSelectedRowKeys.findIndex((item) => item === selectedValue);
369
341
  if (rowKeyIndex > -1) {
370
342
  tempSelectedRows.splice(rowIndex, 1);
371
343
  tempSelectedRowKeys.splice(rowKeyIndex, 1);
@@ -382,18 +354,17 @@ const ProModalSelect = (props, ref) => {
382
354
  selectedRowKeys: tempSelectedRowKeys
383
355
  });
384
356
  };
385
-
386
- // 初始化回显,当传入initParams时,前端用来回险
387
357
  const getInitValues = async () => {
358
+ var _a2, _b2;
388
359
  if (initParams || defaultOne) {
389
360
  const queryBean = {
390
361
  ...defaultParams,
391
- ...(initParams || {})
362
+ ...initParams || {}
392
363
  };
393
364
  const page = {
394
365
  pageNum: 1,
395
366
  pageSize: 10,
396
- ...useRequest?.options?.page
367
+ ...(_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.page
397
368
  };
398
369
  let params = withPagination ? {
399
370
  ...page,
@@ -401,27 +372,25 @@ const ProModalSelect = (props, ref) => {
401
372
  } : queryBean;
402
373
  params = transformParams ? transformParams(params) : params;
403
374
  const res = await runAsync(params);
404
- if (res?.data) {
405
- let list = withPagination ? res?.data?.list : res?.data;
375
+ if (res == null ? void 0 : res.data) {
376
+ let list = withPagination ? (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.list : res == null ? void 0 : res.data;
406
377
  if (transformResponse) {
407
- list = transformResponse(res?.data);
378
+ list = transformResponse(res == null ? void 0 : res.data);
408
379
  }
409
- const data = isMultiple ? list : list?.[0];
410
- if (data) {
380
+ const data2 = isMultiple ? list : list == null ? void 0 : list[0];
381
+ if (data2) {
411
382
  const nextSelectRowKeys = isMultiple ? value : [value];
412
383
  if (labelInValue) {
413
- onChange(data);
414
- preValue.current = data;
384
+ onChange(data2);
385
+ preValue.current = data2;
415
386
  }
416
- // 更新内部展示值
417
387
  setState({
418
- _value: data,
388
+ _value: data2,
419
389
  isInit: false,
420
390
  selectedRows: list,
421
391
  selectedRowKeys: nextSelectRowKeys
422
392
  });
423
- } else if (nextMode === 'input') {
424
- // 当传入initParams且文本框非只读时,不调用接口获取初始化数据
393
+ } else if (nextMode === "input") {
425
394
  setState({
426
395
  _value: value,
427
396
  isInit: false
@@ -430,16 +399,15 @@ const ProModalSelect = (props, ref) => {
430
399
  }
431
400
  }
432
401
  };
433
-
434
- // 初始化回显,当传入initParams时,前端用来回险
435
402
  const getDefaultOneValues = async () => {
403
+ var _a2, _b2;
436
404
  const queryBean = {
437
405
  ...defaultParams
438
406
  };
439
407
  const page = {
440
408
  pageNum: 1,
441
409
  pageSize: 10,
442
- ...useRequest?.options?.page
410
+ ...(_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.page
443
411
  };
444
412
  let params = withPagination ? {
445
413
  ...page,
@@ -447,23 +415,22 @@ const ProModalSelect = (props, ref) => {
447
415
  } : queryBean;
448
416
  params = transformParams ? transformParams(params) : params;
449
417
  const res = await runAsync(params);
450
- if (res?.data) {
451
- let list = withPagination ? res?.data?.list : res?.data;
418
+ if (res == null ? void 0 : res.data) {
419
+ let list = withPagination ? (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.list : res == null ? void 0 : res.data;
452
420
  if (transformResponse) {
453
- list = transformResponse(res?.data);
421
+ list = transformResponse(res == null ? void 0 : res.data);
454
422
  }
455
- const data = isMultiple ? list : list?.[0];
423
+ const data2 = isMultiple ? list : list == null ? void 0 : list[0];
456
424
  const nextSelectRowKeys = isMultiple ? value : [value];
457
425
  if (labelInValue) {
458
- onChange(data);
459
- preValue.current = data;
426
+ onChange(data2);
427
+ preValue.current = data2;
460
428
  } else {
461
- onChange(isMultiple ? data.map(item => item[valueKey]) : data[valueKey]);
462
- preValue.current = isMultiple ? data.map(item => item[valueKey]) : data[valueKey];
429
+ onChange(isMultiple ? data2.map((item) => item[valueKey]) : data2[valueKey]);
430
+ preValue.current = isMultiple ? data2.map((item) => item[valueKey]) : data2[valueKey];
463
431
  }
464
- // 更新内部展示值
465
432
  setState({
466
- _value: data,
433
+ _value: data2,
467
434
  isInit: false,
468
435
  selectedRows: list,
469
436
  selectedRowKeys: nextSelectRowKeys
@@ -477,21 +444,18 @@ const ProModalSelect = (props, ref) => {
477
444
  useMount(() => {
478
445
  if (!value) {
479
446
  setState({
480
- selectedRowKeys: rowSelection?.selectedRowKeys || [],
481
- selectedRows: rowSelection?.selectedRows || [],
482
- _value: undefined
447
+ selectedRowKeys: (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || [],
448
+ selectedRows: (rowSelection == null ? void 0 : rowSelection.selectedRows) || [],
449
+ _value: void 0
483
450
  });
484
- } else if (_isArray(value)) {
451
+ } else if (isArray(value)) {
485
452
  setState({
486
- selectedRowKeys: rowSelection?.selectedRowKeys || value,
487
- selectedRows: rowSelection?.selectedRows || value,
453
+ selectedRowKeys: (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) || value,
454
+ selectedRows: (rowSelection == null ? void 0 : rowSelection.selectedRows) || value,
488
455
  _value: value
489
456
  });
490
- } else if (_isObject(value)) {
491
- const initialValue = {
492
- [valueKey]: value[valueKey],
493
- [labelKey]: value[labelKey]
494
- };
457
+ } else if (isObject(value)) {
458
+ const initialValue = { [valueKey]: value[valueKey], [labelKey]: value[labelKey] };
495
459
  setState({
496
460
  selectedRowKeys: [value],
497
461
  selectedRows: [initialValue],
@@ -500,10 +464,8 @@ const ProModalSelect = (props, ref) => {
500
464
  }
501
465
  });
502
466
  useEffect(() => {
467
+ var _a2;
503
468
  if (onOff && !open) {
504
- if (useRequest?.options?.manual !== true) {
505
- onReset();
506
- }
507
469
  const nextState = {
508
470
  open: true
509
471
  };
@@ -512,43 +474,49 @@ const ProModalSelect = (props, ref) => {
512
474
  nextState.selectedRowKeys = [];
513
475
  nextState.selectedRows = [];
514
476
  }
515
- if (_isObject(value)) {
477
+ if (isObject(value)) {
516
478
  nextState.selectedRowKeys = [getRowKey(value)];
517
479
  nextState.selectedRows = [value];
518
480
  }
519
- if (_isArray(value)) {
520
- nextState.selectedRowKeys = value.map(item => getRowKey(item));
481
+ if (isArray(value)) {
482
+ nextState.selectedRowKeys = value.map((item) => getRowKey(item));
521
483
  nextState.selectedRows = value;
522
484
  }
523
485
  } else if (value) {
524
486
  const nextSelectedRowKeys = isMultiple ? value : [value];
525
487
  nextState.selectedRowKeys = nextSelectedRowKeys;
526
488
  const list = options ?? data;
527
- nextState.selectedRows = list?.filter?.(item => {
489
+ nextState.selectedRows = (_a2 = list == null ? void 0 : list.filter) == null ? void 0 : _a2.call(list, (item) => {
528
490
  return nextSelectedRowKeys.includes(item[valueKey]);
529
491
  });
530
492
  }
531
493
  setState(nextState);
532
494
  }
533
495
  }, [onOff, open, JSON.stringify(value)]);
496
+ useEffect(() => {
497
+ var _a2, _b2;
498
+ if (open && ((_a2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _a2.ready) !== false && ((_b2 = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _b2.manual) === void 0) {
499
+ onSearch(form.getFieldsValue(), true);
500
+ }
501
+ }, [open, (_g = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _g.manual, (_h = useRequest == null ? void 0 : useRequest.options) == null ? void 0 : _h.ready]);
534
502
  useEffect(() => {
535
503
  hideTooltipIfOpen(fieldRef.current, open);
536
504
  }, [open]);
537
505
  useEffect(() => {
538
- if (value && !open && isInit && nextMode === 'input') {
506
+ if (value && !open && isInit && nextMode === "input") {
539
507
  getInitValues();
540
508
  }
541
509
  }, [JSON.stringify(value), open, isInit]);
542
510
  useDebounceEffect(() => {
543
- if (value && !open && nextMode === 'select' && (!_isEqual(value, preValue.current) || options?.length === 0)) {
511
+ var _a2;
512
+ if (value && !open && nextMode === "select" && (!isEqual(value, preValue.current) || (options == null ? void 0 : options.length) === 0)) {
544
513
  preValue.current = value;
545
- const data = labelInValue ? value[valueKey] : value;
546
- const isHasValue = options?.some?.(item => item[valueKey] === data);
514
+ const data2 = labelInValue ? value[valueKey] : value;
515
+ const isHasValue = (_a2 = options == null ? void 0 : options.some) == null ? void 0 : _a2.call(options, (item) => item[valueKey] === data2);
547
516
  if (isHasValue) {
548
517
  return;
549
518
  }
550
519
  if (useRequest) {
551
- // 加定时器 修复依赖数据同步更新未取到问题
552
520
  setTimeout(() => {
553
521
  const params = withPagination ? {
554
522
  pageNum: 1,
@@ -556,19 +524,25 @@ const ProModalSelect = (props, ref) => {
556
524
  queryBean: {
557
525
  ...defaultParams,
558
526
  ...initParams,
559
- [searchKey ?? valueKey]: data
527
+ [searchKey ?? valueKey]: data2
560
528
  }
561
529
  } : {
562
530
  ...defaultParams,
563
531
  ...initParams,
564
- [searchKey ?? valueKey]: data
532
+ [searchKey ?? valueKey]: data2
565
533
  };
566
534
  const nextParams = transformParams ? transformParams(params) : params;
567
535
  run(nextParams);
568
536
  }, 300);
569
537
  }
570
538
  }
571
- }, [JSON.stringify(value), open, JSON.stringify(defaultParams), JSON.stringify(initParams), options?.length]);
539
+ }, [
540
+ JSON.stringify(value),
541
+ open,
542
+ JSON.stringify(defaultParams),
543
+ JSON.stringify(initParams),
544
+ options == null ? void 0 : options.length
545
+ ]);
572
546
  const handleSelectFocus = () => {
573
547
  if (useRequest) {
574
548
  const queryBean = defaultParams || {};
@@ -578,17 +552,16 @@ const ProModalSelect = (props, ref) => {
578
552
  queryBean
579
553
  } : queryBean;
580
554
  const nextParams = transformParams ? transformParams(params) : params;
581
- // 减少请求条件一致时,且请求过时,focus的重复请求
582
- if (!_isEqual(queryBean, defaultParamsRef.current) || !options?.length) {
583
- run(nextParams); // 触发 run 请求
584
- defaultParamsRef.current = queryBean; // 更新缓存
555
+ if (!isEqual(queryBean, defaultParamsRef.current) || !(options == null ? void 0 : options.length)) {
556
+ run(nextParams);
557
+ defaultParamsRef.current = queryBean;
585
558
  }
586
559
  setState({
587
560
  isInit: false
588
561
  });
589
562
  }
590
563
  };
591
- const handleSelectSearch = _debounce(val => {
564
+ const handleSelectSearch = debounce((val) => {
592
565
  if (useRequest) {
593
566
  const queryBean = {
594
567
  ...defaultParams,
@@ -602,28 +575,28 @@ const ProModalSelect = (props, ref) => {
602
575
  const nextParams = transformParams ? transformParams(params) : params;
603
576
  run(nextParams);
604
577
  }
605
- }, 1000);
578
+ }, 1e3);
606
579
  useDebounceEffect(() => {
607
580
  if (!value) {
608
581
  if (defaultOne) {
609
582
  getDefaultOneValues();
610
583
  } else {
611
584
  setState({
612
- _value: undefined,
585
+ _value: void 0,
613
586
  selectedRowKeys: [],
614
587
  selectedRows: []
615
588
  });
616
589
  }
617
590
  }
618
- if (nextMode === 'input') {
619
- if (labelInValue && _value && !_isEqual(value, _value)) {
591
+ if (nextMode === "input") {
592
+ if (labelInValue && _value && !isEqual(value, _value)) {
620
593
  setState({
621
594
  _value: value,
622
595
  selectedRowKeys: [],
623
596
  selectedRows: []
624
597
  });
625
598
  }
626
- if (!labelInValue && !_isEqual(value, _value?.[valueKey])) {
599
+ if (!labelInValue && !isEqual(value, _value == null ? void 0 : _value[valueKey])) {
627
600
  setState({
628
601
  _value: value,
629
602
  selectedRowKeys: [],
@@ -632,132 +605,121 @@ const ProModalSelect = (props, ref) => {
632
605
  }
633
606
  }
634
607
  }, [value, _value]);
635
-
636
- // 加个中间状态Input
637
- let initRender = /*#__PURE__*/_jsxs(Space.Compact, {
638
- style: {
639
- width: '100%'
640
- },
641
- block: true,
642
- children: [nextMode === 'select' ? /*#__PURE__*/_jsx(ProSelect, {
643
- value: value,
644
- onChange: handleSelectValue,
645
- disabled: disabled,
646
- fieldNames: fieldNames,
647
- showCodeName: showCodeName,
648
- labelInValue: labelInValue,
649
- dataSource: options,
650
- optionRender: optionRender,
651
- scrollFollowParent: false,
652
- mode: isMultiple ? 'multiple' : undefined,
653
- notFoundContent: selectLoading ? /*#__PURE__*/_jsx(Spin, {
654
- size: "small"
655
- }) : null,
656
- onFocus: handleSelectFocus,
657
- onSearch: handleSelectSearch,
658
- tooltip: _tooltip,
659
- style: {
660
- width: isView || disabled ? '100%' : 'calc(100% - 30px)'
661
- },
662
- ...restProps
663
- }) : /*#__PURE__*/_jsx(Tooltip, {
664
- title: _tooltip ? viewText : null,
665
- placement: "topLeft",
666
- children: /*#__PURE__*/_jsx(Input, {
608
+ let initRender = /* @__PURE__ */ jsxs(Space.Compact, { style: { width: "100%" }, block: true, children: [
609
+ nextMode === "select" ? /* @__PURE__ */ jsx(
610
+ ProSelect,
611
+ {
612
+ value,
613
+ onChange: handleSelectValue,
614
+ disabled,
615
+ fieldNames,
616
+ showCodeName,
617
+ labelInValue,
618
+ dataSource: options,
619
+ optionRender,
620
+ scrollFollowParent: false,
621
+ mode: isMultiple ? "multiple" : void 0,
622
+ notFoundContent: selectLoading ? /* @__PURE__ */ jsx(Spin, { size: "small" }) : null,
623
+ onFocus: handleSelectFocus,
624
+ onSearch: handleSelectSearch,
625
+ tooltip: _tooltip,
626
+ style: { width: isView || disabled ? "100%" : "calc(100% - 30px)" },
627
+ ...restProps
628
+ }
629
+ ) : /* @__PURE__ */ jsx(Tooltip, { title: _tooltip ? viewText : null, placement: "topLeft", children: /* @__PURE__ */ jsx(
630
+ Input,
631
+ {
667
632
  value: viewText,
668
633
  onChange: handleChangeValue,
669
- disabled: disabled,
634
+ disabled,
670
635
  autoComplete: "off",
671
636
  allowClear: true,
672
637
  ...restProps
673
- })
674
- }), isView || disabled ? null : /*#__PURE__*/_jsx(Button, {
675
- onClick: handleClick,
676
- className: "pro-modal-select-view-button",
677
- icon: /*#__PURE__*/_jsx(ReactSVG, {
678
- className: "viewSvg",
679
- src: viewSvg
680
- })
681
- })]
682
- });
683
- if (customRender && /*#__PURE__*/React.isValidElement(customRender)) {
684
- initRender = /*#__PURE__*/_jsx("div", {
685
- className: "pro-modal-select-init",
686
- onClick: handleClick,
687
- children: customRender
688
- });
638
+ }
639
+ ) }),
640
+ isView || disabled ? null : /* @__PURE__ */ jsx(
641
+ Button,
642
+ {
643
+ onClick: handleClick,
644
+ className: "pro-modal-select-view-button",
645
+ icon: /* @__PURE__ */ jsx(ReactSVG, { className: "viewSvg", src: viewSvg })
646
+ }
647
+ )
648
+ ] });
649
+ if (customRender && React.isValidElement(customRender)) {
650
+ initRender = /* @__PURE__ */ jsx("div", { className: "pro-modal-select-init", onClick: handleClick, children: customRender });
689
651
  }
690
652
  useDeepCompareEffect(() => {
691
653
  setState({
692
- options: tableProps?.dataSource || []
654
+ options: (tableProps == null ? void 0 : tableProps.dataSource) || []
693
655
  });
694
- }, [tableProps?.dataSource]);
695
-
696
- // 当搜索条件只有一个时,且为输入框,默认设置suffix
697
- if (formColumns?.length === 1 && formColumns?.[0]?.type === 'Input') {
698
- if (!formColumns[0]?.fieldProps) {
656
+ }, [tableProps == null ? void 0 : tableProps.dataSource]);
657
+ if ((formColumns == null ? void 0 : formColumns.length) === 1 && ((_i = formColumns == null ? void 0 : formColumns[0]) == null ? void 0 : _i.type) === "Input") {
658
+ if (!((_j = formColumns[0]) == null ? void 0 : _j.fieldProps)) {
699
659
  formColumns[0].fieldProps = {};
700
660
  }
701
- if (!_isFunction(formColumns[0].fieldProps) && !formColumns?.[0]?.fieldProps?.suffix) {
702
- formColumns[0].fieldProps.suffix = /*#__PURE__*/_jsx(SearchOutlined, {
703
- onClick: handleSearch
704
- });
661
+ if (!isFunction(formColumns[0].fieldProps) && !((_l = (_k = formColumns == null ? void 0 : formColumns[0]) == null ? void 0 : _k.fieldProps) == null ? void 0 : _l.suffix)) {
662
+ formColumns[0].fieldProps.suffix = /* @__PURE__ */ jsx(SearchOutlined, { onClick: handleSearch });
705
663
  }
706
664
  }
707
665
  if (isView) {
708
666
  if (!value) {
709
- return /*#__PURE__*/_jsx(_Fragment, {
710
- children: viewEmpty
711
- });
667
+ return /* @__PURE__ */ jsx(Fragment, { children: viewEmpty });
712
668
  }
713
- return /*#__PURE__*/_jsx(Container, {
714
- viewEmpty: viewEmpty,
715
- children: `${viewText}`
716
- });
669
+ return /* @__PURE__ */ jsx(Container, { viewEmpty, children: `${viewText}` });
717
670
  }
718
671
  const _className = classNames({
719
- 'pro-modal-select': true,
672
+ "pro-modal-select": true,
720
673
  [props.className]: props.className,
721
- 'pro-modal-select-open': open
722
- });
723
- return /*#__PURE__*/_jsxs(_Fragment, {
724
- children: [/*#__PURE__*/_jsx("div", {
725
- id: uuid,
726
- className: _className,
727
- style: style,
728
- ref: fieldRef,
729
- children: initRender
730
- }), /*#__PURE__*/_jsxs(ProDrawerForm, {
731
- mode: "Modal",
732
- title: title,
733
- onOk: handleFinish
734
- // @ts-ignore
735
- ,
736
- onCancel: handleClose,
737
- open: open,
738
- ...restModalProps,
739
- children: [/*#__PURE__*/_jsx(ProForm, {
740
- submitOnEnter: true,
741
- form: form,
742
- columns: formColumns,
743
- onFinish: handleSearch,
744
- confirmLoading: loading,
745
- footer: formColumns?.length > 1
746
- }), /*#__PURE__*/_jsx(ProTable, {
747
- onRow: record => {
748
- return {
749
- onClick: () => handleClickRow(record)
750
- };
751
- },
752
- rowKey: rowKey,
753
- loading: loading,
754
- rowSelection: _rowSelection,
755
- columns: columns,
756
- dataSource: data,
757
- pagination: withPagination ? pagination : false,
758
- ...restTableProps
759
- })]
760
- })]
674
+ "pro-modal-select-open": open
761
675
  });
676
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
677
+ /* @__PURE__ */ jsx("div", { id: uuid, className: _className, style, ref: fieldRef, children: initRender }),
678
+ /* @__PURE__ */ jsxs(
679
+ ProDrawerForm,
680
+ {
681
+ mode: "Modal",
682
+ title,
683
+ onOk: handleFinish,
684
+ onCancel: handleClose,
685
+ open,
686
+ ...restModalProps,
687
+ children: [
688
+ /* @__PURE__ */ jsx(
689
+ ProForm,
690
+ {
691
+ submitOnEnter: true,
692
+ form,
693
+ columns: formColumns,
694
+ onFinish: handleSearch,
695
+ onCancel: handleReset,
696
+ confirmLoading: loading,
697
+ footer: (formColumns == null ? void 0 : formColumns.length) > 1
698
+ }
699
+ ),
700
+ /* @__PURE__ */ jsx(
701
+ ProTable,
702
+ {
703
+ onRow: (record) => {
704
+ return {
705
+ onClick: () => handleClickRow(record)
706
+ };
707
+ },
708
+ rowKey,
709
+ loading,
710
+ rowSelection: _rowSelection,
711
+ columns,
712
+ dataSource: data,
713
+ pagination: withPagination ? pagination : false,
714
+ ...restTableProps
715
+ }
716
+ )
717
+ ]
718
+ }
719
+ )
720
+ ] });
721
+ };
722
+ var ProModalSelect_default = forwardRef(ProModalSelect);
723
+ export {
724
+ ProModalSelect_default as default
762
725
  };
763
- export default /*#__PURE__*/forwardRef(ProModalSelect);