@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,11 +1,18 @@
1
- import _omit from "lodash/omit";
2
- import _isArray from "lodash/isArray";
3
- import _isString from "lodash/isString";
4
- import _isFunction from "lodash/isFunction";
5
- import _cloneDeep from "lodash/cloneDeep";
6
- import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
7
- import { message, Radio, Checkbox, Space, Segmented } from 'antd';
8
- import React, { useState, useEffect, useMemo } from 'react';
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ import { useDeepCompareEffect, useRequest as useRequestFunc } from "ahooks";
3
+ import {
4
+ message,
5
+ Radio,
6
+ Checkbox,
7
+ Space,
8
+ Segmented
9
+ } from "antd";
10
+ import React, { useState, useEffect, useMemo } from "react";
11
+ import cloneDeep from "lodash/cloneDeep";
12
+ import isFunction from "lodash/isFunction";
13
+ import isString from "lodash/isString";
14
+ import isArray from "lodash/isArray";
15
+ import omit from "lodash/omit";
9
16
  import ProSelect from "../ProSelect";
10
17
  import { useProConfig } from "../ProConfigProvider";
11
18
  import ProEnumTag from "./components/Tag";
@@ -17,11 +24,11 @@ import useEnum from "./hooks/useEnum";
17
24
  import getEnum from "./utils/getEnum";
18
25
  import locale from "../locale";
19
26
  import { useFieldProps } from "../ProForm/hooks/useFieldProps";
20
- import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
21
- const ProEnum = props => {
27
+ const ProEnum = (props) => {
28
+ var _a, _b, _c, _d, _e, _f, _g, _h;
22
29
  const {
23
30
  code,
24
- type = 'ProSelect',
31
+ type = "ProSelect",
25
32
  dataSource,
26
33
  useRequest,
27
34
  value,
@@ -32,76 +39,69 @@ const ProEnum = props => {
32
39
  isView,
33
40
  ...enumProps
34
41
  } = props;
35
- const {
36
- viewEmpty
37
- } = otherProps || {};
38
- const _defaultValue = props?.defaultValue;
39
- const {
40
- isView: configIsView
41
- } = useFieldProps() || {};
42
+ const { viewEmpty } = otherProps || {};
43
+ const _defaultValue = props == null ? void 0 : props.defaultValue;
44
+ const { isView: configIsView } = useFieldProps() || {};
42
45
  const {
43
46
  fieldNames,
44
47
  clear = true,
45
48
  cacheKey = baseCacheKey,
46
49
  showCodeName,
47
50
  ...resProps
48
- } = useProConfig('ProEnum') || {};
49
- const _isView = isView !== undefined && isView !== null ? isView : otherProps?.isView ?? configIsView;
51
+ } = useProConfig("ProEnum") || {};
52
+ const _isView = isView !== void 0 && isView !== null ? isView : (otherProps == null ? void 0 : otherProps.isView) ?? configIsView;
50
53
  enumProps.showCodeName = enumProps.showCodeName ?? showCodeName;
51
- let label = 'label';
52
- let fieldValue = 'value';
54
+ let label = "label";
55
+ let fieldValue = "value";
53
56
  const [dataList, setData] = useState(dataSource || []);
54
57
  useEffect(() => {
55
- dataSource?.length && setData([...dataSource]);
58
+ (dataSource == null ? void 0 : dataSource.length) && setData([...dataSource]);
56
59
  }, [dataSource]);
57
60
  if (fieldNames && Object.keys(fieldNames).length) {
58
- if (fieldNames?.label) label = fieldNames.label;
59
- if (fieldNames?.value) fieldValue = fieldNames?.value;
61
+ if (fieldNames == null ? void 0 : fieldNames.label)
62
+ label = fieldNames.label;
63
+ if (fieldNames == null ? void 0 : fieldNames.value)
64
+ fieldValue = fieldNames == null ? void 0 : fieldNames.value;
60
65
  }
61
66
  if (props.fieldNames && Object.keys(props.fieldNames).length) {
62
- if (props?.fieldNames?.label) label = props.fieldNames?.label;
63
- if (props?.fieldNames?.value) fieldValue = props.fieldNames?.value;
67
+ if ((_a = props == null ? void 0 : props.fieldNames) == null ? void 0 : _a.label)
68
+ label = (_b = props.fieldNames) == null ? void 0 : _b.label;
69
+ if ((_c = props == null ? void 0 : props.fieldNames) == null ? void 0 : _c.value)
70
+ fieldValue = (_d = props.fieldNames) == null ? void 0 : _d.value;
64
71
  }
65
72
  if (clear) {
66
- label = 'label';
67
- fieldValue = 'value';
73
+ label = "label";
74
+ fieldValue = "value";
68
75
  }
69
-
70
- // 组件显式传入 fieldNames 时优先级最高,必须覆盖 clear 默认映射
71
76
  if (props.fieldNames && Object.keys(props.fieldNames).length) {
72
- if (props.fieldNames?.label) label = props.fieldNames.label;
73
- if (props.fieldNames?.value) fieldValue = props.fieldNames.value;
77
+ if ((_e = props.fieldNames) == null ? void 0 : _e.label)
78
+ label = props.fieldNames.label;
79
+ if ((_f = props.fieldNames) == null ? void 0 : _f.value)
80
+ fieldValue = props.fieldNames.value;
74
81
  }
75
- const {
76
- dics = {}
77
- } = useProConfig('ProEnum');
78
- const {
79
- run
80
- } = useRequestFunc(useRequest?.service, {
82
+ const { dics = {} } = useProConfig("ProEnum");
83
+ const { run } = useRequestFunc(useRequest == null ? void 0 : useRequest.service, {
81
84
  manual: true,
82
85
  cacheTime: -1,
83
- ...useRequest?.options,
84
- onSuccess: res => {
85
- if (transformResponse && typeof transformResponse === 'function') {
86
+ ...useRequest == null ? void 0 : useRequest.options,
87
+ onSuccess: (res) => {
88
+ var _a2, _b2;
89
+ if (transformResponse && typeof transformResponse === "function") {
86
90
  const responseData = transformResponse(res);
87
- if (typeof responseData !== 'object') {
88
- return message.error(locale.ProEnum?.errorMessage);
91
+ if (typeof responseData !== "object") {
92
+ return message.error((_a2 = locale.ProEnum) == null ? void 0 : _a2.errorMessage);
89
93
  }
90
94
  setData(responseData);
91
95
  } else {
92
- const {
93
- status = 200,
94
- message: msg,
95
- data
96
- } = res;
96
+ const { status = 200, message: msg, data } = res;
97
97
  if (status === 200) {
98
- if (typeof data !== 'object') {
99
- return message.error(locale.ProEnum?.errorMessage);
98
+ if (typeof data !== "object") {
99
+ return message.error((_b2 = locale.ProEnum) == null ? void 0 : _b2.errorMessage);
100
100
  }
101
101
  if (Array.isArray(data)) {
102
102
  setData([...data]);
103
103
  }
104
- if (isObject(data) && _isString(code)) {
104
+ if (isObject(data) && isString(code)) {
105
105
  setData(data[code]);
106
106
  }
107
107
  } else {
@@ -110,47 +110,40 @@ const ProEnum = props => {
110
110
  }
111
111
  }
112
112
  });
113
-
114
- // 自定义请求
115
113
  useDeepCompareEffect(() => {
116
- const {
117
- defaultParams
118
- } = useRequest?.options || {};
119
- const params = Array.isArray(defaultParams) ? defaultParams?.[0] : defaultParams || {};
120
- if (useRequest?.service) {
114
+ const { defaultParams } = (useRequest == null ? void 0 : useRequest.options) || {};
115
+ const params = Array.isArray(defaultParams) ? defaultParams == null ? void 0 : defaultParams[0] : defaultParams || {};
116
+ if (useRequest == null ? void 0 : useRequest.service) {
121
117
  run(params);
122
118
  }
123
- }, [useRequest?.options]);
119
+ }, [useRequest == null ? void 0 : useRequest.options]);
124
120
  const enumLists = useMemo(() => {
125
121
  let lists = [];
126
- if (_isString(code)) {
127
- lists = dics?.[code] || [];
122
+ if (isString(code)) {
123
+ lists = (dics == null ? void 0 : dics[code]) || [];
128
124
  }
129
- if (_isArray(code)) {
130
- code.forEach(enumCode => {
131
- _isArray(dics?.[enumCode]) && lists.push(...dics?.[enumCode]);
125
+ if (isArray(code)) {
126
+ code.forEach((enumCode) => {
127
+ isArray(dics == null ? void 0 : dics[enumCode]) && lists.push(...dics == null ? void 0 : dics[enumCode]);
132
128
  });
133
129
  }
134
130
  return lists;
135
131
  }, [dics, code]);
136
132
  const renderComponent = () => {
133
+ var _a2;
137
134
  let list = [];
138
-
139
- // 优先使用组件内部自己传入的数据源或者请求得到的数据
140
135
  const sourceList = dataList && dataList.length ? dataList : enumLists;
141
- // 仅在需要走 transformResponse 时才克隆,避免污染原始字典;
142
- // 否则直接传引用(下游 ProSelect 等仅只读消费),减少滚动重挂载时的 cloneDeep 开销
143
- if (!useRequest?.service && transformResponse) {
144
- list = transformResponse(_cloneDeep(sourceList));
136
+ if (!(useRequest == null ? void 0 : useRequest.service) && transformResponse) {
137
+ list = transformResponse(cloneDeep(sourceList));
145
138
  if (!Array.isArray(list)) {
146
- console.error(locale.ProEnum?.errorArrayMessage);
139
+ console.error((_a2 = locale.ProEnum) == null ? void 0 : _a2.errorArrayMessage);
147
140
  list = [];
148
141
  }
149
142
  } else {
150
143
  list = sourceList;
151
144
  }
152
- if ( /*#__PURE__*/React.isValidElement(component)) {
153
- return /*#__PURE__*/React.cloneElement(component, {
145
+ if (React.isValidElement(component)) {
146
+ return React.cloneElement(component, {
154
147
  ...enumProps,
155
148
  dataSource: list,
156
149
  fieldNames: {
@@ -162,139 +155,136 @@ const ProEnum = props => {
162
155
  });
163
156
  }
164
157
  switch (type) {
165
- case 'ProSelect':
166
- return /*#__PURE__*/_jsx(ProSelect, {
167
- ..._omit(enumProps, ['ref']),
168
- otherProps: otherProps,
169
- dataSource: list,
170
- fieldNames: {
171
- label,
172
- value: fieldValue
173
- },
174
- value: value,
175
- onChange: onChange
176
- });
177
- case 'Radio':
178
- return /*#__PURE__*/_jsx(Radio.Group, {
179
- ..._omit(enumProps, ['fieldNames', 'showCodeName']),
180
- options: list,
181
- value: value,
182
- onChange: onChange,
183
- children: list.map(item => /*#__PURE__*/_jsx(Radio, {
184
- value: item[fieldValue],
185
- disabled: !!item.disabled,
186
- children: item[label]
187
- }, item[fieldValue]))
188
- });
189
- case 'Checkbox':
190
- return /*#__PURE__*/_jsx(Checkbox.Group, {
191
- ..._omit(enumProps, ['fieldNames', 'showCodeName']),
192
- options: list,
193
- value: value,
194
- onChange: onChange,
195
- children: list.map(item => /*#__PURE__*/_jsx(Checkbox, {
196
- value: item[fieldValue],
197
- disabled: !!item.disabled,
198
- children: item[label]
199
- }, item[fieldValue]))
200
- });
201
- case 'Tag':
202
- return /*#__PURE__*/_jsx(ProEnumTag, {
203
- id: enumProps.id,
204
- value: value,
205
- onChange: onChange,
206
- fieldLabel: label,
207
- fieldValue: fieldValue,
208
- dataSource: list
209
- });
210
- case 'Group':
211
- return /*#__PURE__*/_jsx(ProEnumGroup, {
212
- ..._omit(enumProps, ['showCodeName']),
213
- value: value,
214
- onChange: onChange,
215
- fieldLabel: label,
216
- fieldValue: fieldValue,
217
- dataSource: list
218
- });
219
- case 'Segmented':
220
- return /*#__PURE__*/_jsx(Segmented, {
221
- ..._omit(enumProps, ['fieldNames', 'showCodeName']),
222
- options: list.map(item => ({
223
- label: item[label],
224
- value: item[fieldValue],
225
- disabled: !!item.disabled
226
- })),
227
- value: value,
228
- onChange: onChange
229
- });
158
+ case "ProSelect":
159
+ return /* @__PURE__ */ jsx(
160
+ ProSelect,
161
+ {
162
+ ...omit(enumProps, ["ref"]),
163
+ otherProps,
164
+ dataSource: list,
165
+ fieldNames: {
166
+ label,
167
+ value: fieldValue
168
+ },
169
+ value,
170
+ onChange
171
+ }
172
+ );
173
+ case "Radio":
174
+ return /* @__PURE__ */ jsx(
175
+ Radio.Group,
176
+ {
177
+ ...omit(enumProps, ["fieldNames", "showCodeName"]),
178
+ options: list,
179
+ value,
180
+ onChange,
181
+ children: list.map((item) => /* @__PURE__ */ jsx(Radio, { value: item[fieldValue], disabled: !!item.disabled, children: item[label] }, item[fieldValue]))
182
+ }
183
+ );
184
+ case "Checkbox":
185
+ return /* @__PURE__ */ jsx(
186
+ Checkbox.Group,
187
+ {
188
+ ...omit(enumProps, ["fieldNames", "showCodeName"]),
189
+ options: list,
190
+ value,
191
+ onChange,
192
+ children: list.map((item) => /* @__PURE__ */ jsx(Checkbox, { value: item[fieldValue], disabled: !!item.disabled, children: item[label] }, item[fieldValue]))
193
+ }
194
+ );
195
+ case "Tag":
196
+ return /* @__PURE__ */ jsx(
197
+ ProEnumTag,
198
+ {
199
+ id: enumProps.id,
200
+ value,
201
+ onChange,
202
+ fieldLabel: label,
203
+ fieldValue,
204
+ dataSource: list
205
+ }
206
+ );
207
+ case "Group":
208
+ return /* @__PURE__ */ jsx(
209
+ ProEnumGroup,
210
+ {
211
+ ...omit(enumProps, ["showCodeName"]),
212
+ value,
213
+ onChange,
214
+ fieldLabel: label,
215
+ fieldValue,
216
+ dataSource: list
217
+ }
218
+ );
219
+ case "Segmented":
220
+ return /* @__PURE__ */ jsx(
221
+ Segmented,
222
+ {
223
+ ...omit(enumProps, ["fieldNames", "showCodeName"]),
224
+ options: list.map((item) => ({
225
+ label: item[label],
226
+ value: item[fieldValue],
227
+ disabled: !!item.disabled
228
+ })),
229
+ value,
230
+ onChange
231
+ }
232
+ );
230
233
  default:
231
234
  return null;
232
235
  }
233
236
  };
234
237
  if (!code && !dataSource && !useRequest) {
235
- message.error(`${otherProps?.label}-${otherProps?.name}-${locale?.ProEnum?.errorNoEnumType}`);
238
+ message.error(`${otherProps == null ? void 0 : otherProps.label}-${otherProps == null ? void 0 : otherProps.name}-${(_h = (_g = locale) == null ? void 0 : _g.ProEnum) == null ? void 0 : _h.errorNoEnumType}`);
236
239
  }
237
- const transToLabel = value => {
240
+ const transToLabel = (value2) => {
238
241
  const list = dataList && dataList.length ? dataList : enumLists;
239
242
  if (!Array.isArray(list) || !list.length) {
240
243
  return viewEmpty;
241
244
  }
242
- const labelList = value.map(v => {
243
- const option = list.find(item => {
245
+ const labelList = value2.map((v) => {
246
+ const option = list.find((item) => {
244
247
  if (enumProps.labelInValue) {
245
- return item[fieldValue] === v?.[fieldValue];
248
+ return item[fieldValue] === (v == null ? void 0 : v[fieldValue]);
246
249
  }
247
250
  return item[fieldValue] === v;
248
251
  }) || {};
249
252
  if (!option) {
250
- return '';
253
+ return "";
251
254
  }
252
- return enumProps.showCodeName ? `${option?.[fieldValue]}-${option?.[label]}` : option?.[label];
255
+ return enumProps.showCodeName ? `${option == null ? void 0 : option[fieldValue]}-${option == null ? void 0 : option[label]}` : option == null ? void 0 : option[label];
253
256
  });
254
- const record = value.map(v => {
255
- return list.find(item => {
257
+ const record = value2.map((v) => {
258
+ return list.find((item) => {
256
259
  return item[fieldValue] === v;
257
260
  });
258
261
  });
259
- // 自定义option时,默认取optionRender的值
260
262
  const _optionRender = () => {
261
263
  if (!record.length) {
262
264
  return viewEmpty;
263
265
  }
264
266
  const arr = [];
265
- record.forEach(item => {
267
+ record.forEach((item) => {
266
268
  arr.push(props.optionRender(item));
267
269
  });
268
- return /*#__PURE__*/_jsx(Space, {
269
- orientation: "vertical",
270
- size: 4,
271
- children: arr.map(item => /*#__PURE__*/_jsx(React.Fragment, {
272
- children: item
273
- }, item))
274
- });
270
+ return /* @__PURE__ */ jsx(Space, { orientation: "vertical", size: 4, children: arr.map((item) => /* @__PURE__ */ jsx(React.Fragment, { children: item }, item)) });
275
271
  };
276
- const filteredLabelList = labelList?.filter(item => item != null && item !== '');
277
- return _isFunction(props.optionRender) && record.length ? _optionRender() : filteredLabelList?.length ? filteredLabelList.join('') : null;
272
+ const filteredLabelList = labelList == null ? void 0 : labelList.filter((item) => item != null && item !== "");
273
+ return isFunction(props.optionRender) && record.length ? _optionRender() : (filteredLabelList == null ? void 0 : filteredLabelList.length) ? filteredLabelList.join("") : null;
278
274
  };
279
275
  if (_isView) {
280
276
  const __value = value ?? _defaultValue;
281
277
  if (Array.isArray(__value)) {
282
- return /*#__PURE__*/_jsx(Container, {
283
- tooltip: true,
284
- viewEmpty: viewEmpty,
285
- children: transToLabel(__value)
286
- });
278
+ return /* @__PURE__ */ jsx(Container, { tooltip: true, viewEmpty, children: transToLabel(__value) });
287
279
  }
288
- return /*#__PURE__*/_jsx(Container, {
289
- viewEmpty: viewEmpty,
290
- children: __value != null ? transToLabel([__value]) : null
291
- });
280
+ return /* @__PURE__ */ jsx(Container, { viewEmpty, children: __value != null ? transToLabel([__value]) : null });
292
281
  }
293
- return /*#__PURE__*/_jsx(_Fragment, {
294
- children: renderComponent()
295
- });
282
+ return /* @__PURE__ */ jsx(Fragment, { children: renderComponent() });
296
283
  };
297
284
  ProEnum.getEnumLabel = getEnumLabel;
298
285
  ProEnum.useEnum = useEnum;
299
286
  ProEnum.getEnum = getEnum;
300
- export default ProEnum;
287
+ var ProEnum_default = ProEnum;
288
+ export {
289
+ ProEnum_default as default
290
+ };
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +1,8 @@
1
- import _isFunction from "lodash/isFunction";
2
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
4
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
+ import isFunction from "lodash/isFunction";
5
2
  class SimpleEventCenter {
3
+ events;
6
4
  constructor() {
7
- _defineProperty(this, "events", void 0);
8
- this.events = new Map();
5
+ this.events = /* @__PURE__ */ new Map();
9
6
  }
10
7
  subscribe(eventName, callback) {
11
8
  if (!this.events.has(eventName)) {
@@ -15,17 +12,18 @@ class SimpleEventCenter {
15
12
  }
16
13
  publish(eventName, data) {
17
14
  if (this.events.has(eventName)) {
18
- this.events.get(eventName).forEach(callback => {
19
- _isFunction(callback) && callback?.(data);
15
+ this.events.get(eventName).forEach((callback) => {
16
+ isFunction(callback) && (callback == null ? void 0 : callback(data));
20
17
  });
21
18
  }
22
19
  }
23
20
  unsubscribe(eventName, callback) {
24
21
  if (this.events.has(eventName)) {
25
- this.events.set(eventName, this.events.get(eventName).filter(cb => cb !== callback));
22
+ this.events.set(
23
+ eventName,
24
+ this.events.get(eventName).filter((cb) => cb !== callback)
25
+ );
26
26
  }
27
27
  }
28
28
  }
29
-
30
- // 将 eventCenter 实例添加到 window 对象上
31
- window.eventCenter = new SimpleEventCenter();
29
+ window.eventCenter = new SimpleEventCenter();
@@ -1,38 +1,23 @@
1
- import { getEnumData, setEnumData, cacheFieldNames, baseCacheKey, normalizeEnumCacheData } from "./index";
2
-
3
- /**
4
- * 替换频繁枚举缓存数据的参数接口
5
- */
6
-
7
- /**
8
- * IndexedDB 异步版本的替换频繁枚举缓存数据
9
- */
1
+ import {
2
+ getEnumData,
3
+ setEnumData,
4
+ cacheFieldNames,
5
+ baseCacheKey,
6
+ normalizeEnumCacheData
7
+ } from "./index";
10
8
  async function replaceFrequentEnumCacheAsync(params) {
11
- const {
12
- storage,
13
- cacheKey,
14
- enums,
15
- newData,
16
- fieldNames,
17
- clear
18
- } = params;
19
- const cacheData = normalizeEnumCacheData(await Promise.resolve(getEnumData(storage, cacheKey) || {
20
- data: {}
21
- }));
22
-
23
- // 确保cacheData.data存在
9
+ const { storage, cacheKey, enums, newData, fieldNames, clear } = params;
10
+ const cacheData = normalizeEnumCacheData(
11
+ await Promise.resolve(getEnumData(storage, cacheKey) || { data: {} })
12
+ );
24
13
  if (!cacheData.data) {
25
14
  cacheData.data = {};
26
15
  }
27
-
28
- // 只替换指定的枚举
29
- enums.forEach(code => {
16
+ enums.forEach((code) => {
30
17
  if (newData[code]) {
31
18
  let processedData = newData[code];
32
-
33
- // 应用数据清洗逻辑
34
19
  if (clear && Array.isArray(processedData)) {
35
- processedData = processedData.map(item => {
20
+ processedData = processedData.map((item) => {
36
21
  return cacheFieldNames(fieldNames, item);
37
22
  });
38
23
  }
@@ -44,66 +29,36 @@ async function replaceFrequentEnumCacheAsync(params) {
44
29
  await Promise.resolve(setEnumData(storage, cacheKey, normalizedCacheData));
45
30
  return normalizedCacheData;
46
31
  }
47
-
48
- /**
49
- * 替换频繁枚举缓存数据
50
- * @param params 参数对象
51
- * @returns 更新后的缓存数据
52
- */
53
- export function replaceFrequentEnumCache(params) {
32
+ function replaceFrequentEnumCache(params) {
54
33
  const {
55
- storage = 'localStorage',
34
+ storage = "localStorage",
56
35
  cacheKey = baseCacheKey,
57
36
  enums = [],
58
37
  newData = {},
59
- fieldNames = {
60
- label: 'label',
61
- value: 'value',
62
- children: 'children'
63
- },
38
+ fieldNames = { label: "label", value: "value", children: "children" },
64
39
  clear = true
65
40
  } = params;
66
-
67
- // 参数验证
68
41
  if (!storage || !cacheKey) {
69
- console.warn('ProEnum: storage and cacheKey are required for replaceFrequentEnumCache');
70
- return {
71
- data: {}
72
- };
42
+ console.warn("ProEnum: storage and cacheKey are required for replaceFrequentEnumCache");
43
+ return { data: {} };
73
44
  }
74
45
  if (!enums.length) {
75
- console.warn('ProEnum: enums array is empty, no data to replace');
76
- return {
77
- data: {}
78
- };
46
+ console.warn("ProEnum: enums array is empty, no data to replace");
47
+ return { data: {} };
79
48
  }
80
-
81
- // IndexedDB 异步处理
82
- if (storage === 'indexedDB') {
49
+ if (storage === "indexedDB") {
83
50
  return replaceFrequentEnumCacheAsync(params);
84
51
  }
85
-
86
- // localStorage/sessionStorage 同步处理(保持原逻辑)
87
52
  const cacheDataResult = getEnumData(storage, cacheKey);
88
- // getEnumData 对于非 indexedDB 返回同步值,对于 indexedDB 返回 Promise
89
- // 这里 storage 不是 indexedDB,所以是同步值
90
- const cacheData = normalizeEnumCacheData(cacheDataResult || {
91
- data: {}
92
- });
93
-
94
- // 确保cacheData.data存在
53
+ const cacheData = normalizeEnumCacheData(cacheDataResult || { data: {} });
95
54
  if (!cacheData.data) {
96
55
  cacheData.data = {};
97
56
  }
98
-
99
- // 只替换指定的枚举
100
- enums.forEach(code => {
57
+ enums.forEach((code) => {
101
58
  if (newData[code]) {
102
59
  let processedData = newData[code];
103
-
104
- // 应用数据清洗逻辑
105
60
  if (clear && Array.isArray(processedData)) {
106
- processedData = processedData.map(item => {
61
+ processedData = processedData.map((item) => {
107
62
  return cacheFieldNames(fieldNames, item);
108
63
  });
109
64
  }
@@ -115,27 +70,15 @@ export function replaceFrequentEnumCache(params) {
115
70
  setEnumData(storage, cacheKey, normalizedCacheData);
116
71
  return normalizedCacheData;
117
72
  }
118
-
119
- /**
120
- * 验证频繁枚举配置
121
- * @param config 频繁枚举配置
122
- * @returns 是否有效
123
- */
124
- export function validateFrequentEnumConfig(config) {
125
- return !!(config?.enums?.length && config?.service);
73
+ function validateFrequentEnumConfig(config) {
74
+ var _a;
75
+ return !!(((_a = config == null ? void 0 : config.enums) == null ? void 0 : _a.length) && (config == null ? void 0 : config.service));
76
+ }
77
+ function mergeFrequentEnumData(cacheData, dics, dataSource) {
78
+ return { ...dics, ...dataSource, ...cacheData.data };
126
79
  }
127
-
128
- /**
129
- * 合并频繁枚举数据到全局状态
130
- * @param cacheData 缓存数据
131
- * @param dics 现有字典数据
132
- * @param dataSource 数据源
133
- * @returns 合并后的数据
134
- */
135
- export function mergeFrequentEnumData(cacheData, dics, dataSource) {
136
- return {
137
- ...dics,
138
- ...dataSource,
139
- ...cacheData.data
140
- };
141
- }
80
+ export {
81
+ mergeFrequentEnumData,
82
+ replaceFrequentEnumCache,
83
+ validateFrequentEnumConfig
84
+ };