@unicom-cloud/ui 0.8.44 → 0.8.46

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 (489) hide show
  1. package/Affix.js +54 -51
  2. package/Alert.js +46 -43
  3. package/Anchor.js +5 -4
  4. package/AutoComplete.js +60 -55
  5. package/Avatar.js +10 -155
  6. package/BackTop.js +41 -38
  7. package/Badge.js +63 -93
  8. package/Breadcrumb.js +63 -118
  9. package/Button.js +105 -109
  10. package/Calendar.js +139 -536
  11. package/Card.js +65 -101
  12. package/Carousel.js +169 -270
  13. package/Cascader.js +9 -8
  14. package/Checkbox.js +4 -3
  15. package/Collapse.js +4 -3
  16. package/ColorPicker.js +95 -546
  17. package/Comment.js +14 -12
  18. package/ConfigProvider.js +6 -5
  19. package/Copy.js +33 -31
  20. package/DatePicker.js +35 -1993
  21. package/Descriptions.js +30 -28
  22. package/Divider.js +8 -6
  23. package/Draggable.js +28 -85
  24. package/Drawer.js +5 -4
  25. package/Dropdown.js +107 -167
  26. package/Empty.js +28 -8
  27. package/Form.js +30 -1418
  28. package/Grid.js +13 -250
  29. package/Icon.js +19 -45
  30. package/IconHover.js +39 -6
  31. package/Image.js +3 -3
  32. package/Input.js +4 -4
  33. package/InputNumber.js +213 -17
  34. package/InputTag.js +5 -4
  35. package/Layout.js +35 -48
  36. package/Link.js +16 -14
  37. package/List.js +191 -228
  38. package/Loading.js +18 -17
  39. package/Mentions.js +99 -115
  40. package/Menu.js +8 -7
  41. package/Message.js +147 -10
  42. package/Modal.js +5 -4
  43. package/Notice.js +196 -13
  44. package/Notification.js +136 -11
  45. package/NotificationBase.js +5 -4
  46. package/OverflowEllipsis.js +48 -71
  47. package/PageHeader.js +52 -52
  48. package/Pagination.js +12 -11
  49. package/Picker.js +6 -4
  50. package/Popconfirm.js +47 -44
  51. package/Popover.js +25 -23
  52. package/Portal.js +12 -32
  53. package/Progress.js +65 -328
  54. package/Radio.js +6 -5
  55. package/Rate.js +48 -45
  56. package/ResizeBox.js +127 -505
  57. package/Result.js +60 -1417
  58. package/Select.js +9 -8
  59. package/SelectView.js +49 -328
  60. package/Skeleton.js +41 -78
  61. package/Slider.js +228 -702
  62. package/Space.js +53 -57
  63. package/Spin.js +57 -72
  64. package/Statistic.js +84 -153
  65. package/Steps.js +64 -123
  66. package/SuspenseFallbackTest.js +4 -3
  67. package/Switch.js +41 -38
  68. package/Table.js +20 -1999
  69. package/Tabs.js +9 -8
  70. package/Tag.js +24 -21
  71. package/TimePicker.js +19 -272
  72. package/Timeline.js +4 -3
  73. package/Tooltip.js +79 -72
  74. package/Transfer.js +138 -402
  75. package/Tree.js +5 -4
  76. package/TreeSelect.js +8 -7
  77. package/Trigger.js +407 -571
  78. package/Typography.js +11 -722
  79. package/Upload.js +9 -8
  80. package/VerificationCode.js +6 -5
  81. package/Version.js +1 -1
  82. package/VirtualList.js +4 -3
  83. package/Watermark.js +3 -2
  84. package/anchor/Anchor.js +193 -0
  85. package/anchor/Link.js +54 -0
  86. package/anchor/context.js +14 -0
  87. package/anchor/util.js +41 -0
  88. package/avatar/Avatar.js +85 -0
  89. package/avatar/Group.js +84 -0
  90. package/avatar/context.js +5 -0
  91. package/badge/Count.js +35 -0
  92. package/breadcrumb/Item.js +67 -0
  93. package/button/Group.js +15 -0
  94. package/calendar/Month.js +142 -0
  95. package/calendar/WeekList.js +24 -0
  96. package/calendar/Year.js +75 -0
  97. package/calendar/header/Panel.js +57 -0
  98. package/calendar/header/index.js +118 -0
  99. package/calendar/hook/useCellClassName.js +41 -0
  100. package/card/Grid.js +27 -0
  101. package/card/Meta.js +32 -0
  102. package/carousel/Arrow.js +57 -0
  103. package/carousel/Indicator.js +68 -0
  104. package/cascader/Cascader.js +300 -0
  105. package/cascader/base/node.js +142 -0
  106. package/cascader/base/store.js +93 -0
  107. package/cascader/hook/useRefCurrent.js +12 -0
  108. package/cascader/panel/List.js +275 -0
  109. package/cascader/panel/Option.js +35 -0
  110. package/cascader/panel/Search.js +171 -0
  111. package/cascader/util.js +66 -0
  112. package/checkbox/Checkbox.js +111 -0
  113. package/checkbox/Group.js +97 -0
  114. package/checkbox/useCheckbox.js +45 -0
  115. package/collapse/Collapse.js +90 -0
  116. package/collapse/Item.js +165 -0
  117. package/color-picker/ControlBar.js +64 -0
  118. package/color-picker/InputAlpha.js +24 -0
  119. package/color-picker/InputHex.js +59 -0
  120. package/color-picker/InputRgb.js +66 -0
  121. package/color-picker/Palette.js +36 -0
  122. package/color-picker/Panel.js +165 -0
  123. package/color-picker/colors.js +37 -0
  124. package/color-picker/hooks/useColorPicker.js +63 -0
  125. package/color-picker/hooks/useControlBlock.js +40 -0
  126. package/config-provider/ConfigProvider.js +94 -0
  127. package/config-provider/context.js +24 -0
  128. package/date-picker/Picker.js +399 -0
  129. package/date-picker/PickerRange.js +568 -0
  130. package/date-picker/context.js +5 -0
  131. package/date-picker/hook/useCellClassName.js +58 -0
  132. package/date-picker/panel/Body.js +78 -0
  133. package/date-picker/panel/Footer.js +71 -0
  134. package/date-picker/panel/Header.js +74 -0
  135. package/date-picker/panel/Shortcut.js +45 -0
  136. package/date-picker/panel/WeekList.js +19 -0
  137. package/date-picker/panel/date/index.js +194 -0
  138. package/date-picker/panel/month/index.js +113 -0
  139. package/date-picker/panel/quarter/index.js +93 -0
  140. package/date-picker/panel/range/index.js +251 -0
  141. package/date-picker/panel/week/index.js +35 -0
  142. package/date-picker/panel/year/index.js +74 -0
  143. package/date-picker/util.js +69 -0
  144. package/draggable/Item.js +66 -0
  145. package/drawer/Drawer.js +226 -0
  146. package/dropdown/Button.js +91 -0
  147. package/form/Control.js +264 -0
  148. package/form/Form.js +156 -0
  149. package/form/FormItem.js +241 -0
  150. package/form/FormLabel.js +54 -0
  151. package/form/FormList.js +96 -0
  152. package/form/FormProvider.js +48 -0
  153. package/form/IconSymbol.js +20 -0
  154. package/form/context.js +43 -0
  155. package/form/hook/useContext.js +32 -0
  156. package/form/hook/useState.js +31 -0
  157. package/form/hook/useWatch.js +36 -0
  158. package/form/interface.js +11 -0
  159. package/form/promisify.js +23 -0
  160. package/form/store.js +354 -0
  161. package/form/useForm.js +53 -0
  162. package/form/util.js +72 -0
  163. package/grid/Col.js +87 -0
  164. package/grid/Row.js +88 -0
  165. package/grid/context.js +9 -0
  166. package/grid/grid-item.js +77 -0
  167. package/grid/grid.js +104 -0
  168. package/grid/hook/useResponsiveState.js +38 -0
  169. package/grid/util.js +51 -0
  170. package/{chunk/I4RV9SKZ.js → hooks/factory/createHTMLMediaHook.js} +35 -43
  171. package/hooks/index.js +246 -4
  172. package/{chunk/BdYAMaw9.js → hooks/misc/hookState.js} +1 -1
  173. package/hooks/misc/parseTimeRanges.js +12 -0
  174. package/{chunk/TXCrI0jN.js → hooks/misc/util.js} +6 -6
  175. package/hooks/use-watermark/utils.js +8 -0
  176. package/hooks/use-watermark.js +71 -76
  177. package/hooks/useAudio.js +3 -3
  178. package/hooks/useBeforeUnload.js +2 -2
  179. package/hooks/useClickAway.js +10 -10
  180. package/hooks/useCounter.js +1 -1
  181. package/hooks/useCreation.js +2 -4
  182. package/hooks/useDrop.js +12 -12
  183. package/hooks/useDropArea.js +5 -5
  184. package/hooks/useEvent.js +6 -6
  185. package/hooks/useEventListener.js +2 -4
  186. package/hooks/useFavicon.js +1 -2
  187. package/hooks/useFullscreen.js +11 -13
  188. package/hooks/useGetSet.js +5 -5
  189. package/hooks/useHash.js +6 -6
  190. package/hooks/useHover.js +6 -6
  191. package/hooks/useHoverDirty.js +7 -7
  192. package/hooks/useIdle.js +17 -17
  193. package/hooks/useIsomorphicLayoutEffect2.js +3 -3
  194. package/hooks/useKey.js +5 -5
  195. package/hooks/useList.js +1 -1
  196. package/hooks/useLocalStorage.js +2 -3
  197. package/hooks/useLocation.js +1 -1
  198. package/hooks/useLockBodyScroll.js +13 -14
  199. package/hooks/useLongPress.js +7 -7
  200. package/hooks/useMeasure.js +3 -3
  201. package/hooks/useMedia.js +4 -4
  202. package/hooks/useMediaDevices.js +10 -10
  203. package/hooks/useMotion.js +11 -11
  204. package/hooks/useMouse.js +9 -9
  205. package/hooks/useMouseWheel.js +7 -7
  206. package/hooks/useNetworkState.js +7 -7
  207. package/hooks/useOrientation.js +10 -11
  208. package/hooks/useOverrideRef.js +14 -0
  209. package/hooks/usePageLeave.js +4 -4
  210. package/hooks/usePermission.js +9 -9
  211. package/hooks/usePersistCallback.js +15 -0
  212. package/hooks/useScroll.js +6 -6
  213. package/hooks/useScrolling.js +7 -7
  214. package/hooks/useSearchParam.js +5 -5
  215. package/hooks/useSessionStorage.js +9 -9
  216. package/hooks/useSize.js +1 -1
  217. package/hooks/useSlider.js +6 -6
  218. package/hooks/useStartTyping.js +4 -4
  219. package/hooks/useStateList.js +4 -5
  220. package/hooks/useStateWithHistory.js +1 -1
  221. package/hooks/useTimeout.js +1 -2
  222. package/hooks/useVibrate.js +5 -5
  223. package/hooks/useVideo.js +3 -3
  224. package/hooks/useWindowScroll.js +13 -13
  225. package/hooks/useWindowSize.js +6 -6
  226. package/icon/addFromIconFontCn.js +33 -0
  227. package/image/Image.js +189 -0
  228. package/image/ImageFooter.js +45 -0
  229. package/image/ImagePreview.js +473 -0
  230. package/image/ImagePreviewArrow.js +40 -0
  231. package/image/ImagePreviewGroup.js +125 -0
  232. package/image/ImagePreviewToolbar.js +98 -0
  233. package/image/TriggerForToolbar.js +10 -0
  234. package/image/previewGroupContext.js +17 -0
  235. package/image/util/getFixTranslate.js +7 -0
  236. package/image/util/getScale.js +72 -0
  237. package/image/util/hook/useImageStatus.js +16 -0
  238. package/image/util/hook/useShowFooter.js +7 -0
  239. package/index.js +440 -398
  240. package/input/Group.js +20 -0
  241. package/input/Input.js +185 -0
  242. package/input/InputElement.js +233 -0
  243. package/input/Number.js +4 -0
  244. package/input/Password.js +72 -0
  245. package/input/Search.js +80 -0
  246. package/input/Tag.js +7 -0
  247. package/input/Textarea.js +168 -0
  248. package/input/autoSizeTextAreaHeight.js +65 -0
  249. package/input/useComposition.js +39 -0
  250. package/input-number/decimal.js +154 -0
  251. package/input-number/useSelectionRange.js +26 -0
  252. package/input-number/util.js +57 -0
  253. package/input-tag/InputTag.js +381 -0
  254. package/layout/Content.js +15 -0
  255. package/layout/Footer.js +15 -0
  256. package/layout/Header.js +15 -0
  257. package/{chunk/B9asjXwm.js → layout/Sider.js} +23 -22
  258. package/list/Item.js +46 -0
  259. package/list/Meta.js +21 -0
  260. package/loading/style/index.module.less.js +4 -0
  261. package/mentions/util.js +26 -0
  262. package/menu/Indent.js +17 -0
  263. package/menu/Item.js +125 -0
  264. package/menu/ItemGroup.js +39 -0
  265. package/menu/Menu.js +181 -0
  266. package/menu/OverflowWrap.js +85 -0
  267. package/menu/context.js +5 -0
  268. package/menu/sub-menu/Inline.js +111 -0
  269. package/menu/sub-menu/Pop.js +126 -0
  270. package/menu/sub-menu/index.js +17 -0
  271. package/menu/util.js +80 -0
  272. package/message/useMessage.js +53 -0
  273. package/modal/Confirm.js +98 -0
  274. package/modal/Modal.js +419 -0
  275. package/modal/config.js +25 -0
  276. package/modal/use-modal/Hook.js +55 -0
  277. package/modal/use-modal/index.js +68 -0
  278. package/notification/useNotification.js +55 -0
  279. package/overflow-ellipsis/OverflowItem.js +34 -0
  280. package/package.json +1 -1
  281. package/pagination/PageItem.js +121 -0
  282. package/pagination/PageJumper.js +64 -0
  283. package/pagination/PageOption.js +55 -0
  284. package/pagination/Pagination.js +245 -0
  285. package/picker/Input.js +124 -0
  286. package/picker/InputRange.js +155 -0
  287. package/portal/Portal.js +25 -0
  288. package/progress/CircleProgress.js +117 -0
  289. package/progress/LineProgess.js +103 -0
  290. package/progress/StepProgress.js +74 -0
  291. package/radio/Group.js +91 -0
  292. package/radio/Radio.js +90 -0
  293. package/resize-box/ResizeTrigger.js +78 -0
  294. package/resize-box/Split.js +132 -0
  295. package/resize-box/SplitGroup.js +204 -0
  296. package/result/403.js +695 -0
  297. package/result/404.js +513 -0
  298. package/result/500.js +166 -0
  299. package/select/OptGroup.js +20 -0
  300. package/select/Option.js +97 -0
  301. package/select/Select.js +544 -0
  302. package/select/util.js +140 -0
  303. package/select-view/Core.js +309 -0
  304. package/skeleton/Image.js +24 -0
  305. package/skeleton/Text.js +27 -0
  306. package/slider/Button.js +159 -0
  307. package/slider/Dot.js +43 -0
  308. package/slider/Input.js +75 -0
  309. package/slider/Mark.js +28 -0
  310. package/slider/Tick.js +44 -0
  311. package/slider/hook/useInterval.js +73 -0
  312. package/slider/hook/useLegalValue.js +70 -0
  313. package/slider/util.js +63 -0
  314. package/space/toArray.js +11 -0
  315. package/spin/DotLoading.js +26 -0
  316. package/statistic/Countdown.js +57 -0
  317. package/statistic/util.js +33 -0
  318. package/steps/Step.js +68 -0
  319. package/style.css +1 -1
  320. package/table/ColGroup.js +59 -0
  321. package/table/Table.js +634 -0
  322. package/table/constant.js +5 -0
  323. package/table/hook/useColumns.js +141 -0
  324. package/table/hook/useComponent.js +64 -0
  325. package/table/hook/useExpand.js +36 -0
  326. package/table/hook/useRowSelection.js +92 -0
  327. package/table/hook/useSorter.js +54 -0
  328. package/table/hook/useStickyClassNames.js +30 -0
  329. package/table/hook/useStickyOffsets.js +30 -0
  330. package/table/summary/Cell.js +10 -0
  331. package/table/summary/Row.js +26 -0
  332. package/table/summary/context.js +5 -0
  333. package/table/summary/index.js +10 -0
  334. package/table/tbody/Td.js +168 -0
  335. package/table/tbody/Tr.js +168 -0
  336. package/table/tbody/index.js +156 -0
  337. package/table/tfoot/index.js +16 -0
  338. package/table/thead/Column.js +250 -0
  339. package/table/thead/index.js +131 -0
  340. package/table/util.js +121 -0
  341. package/tabs/Tab.js +170 -0
  342. package/tabs/TabContent.js +54 -0
  343. package/tabs/TabPane.js +26 -0
  344. package/tabs/hook/useDomSize.js +17 -0
  345. package/tabs/hook/useHeaderScroll.js +64 -0
  346. package/tabs/tab-header/DropdownIcon.js +71 -0
  347. package/tabs/tab-header/TabInk.js +65 -0
  348. package/tabs/tab-header/TabNavIcon.js +65 -0
  349. package/tabs/tab-header/TabTitle.js +78 -0
  350. package/tabs/tab-header/index.js +335 -0
  351. package/tabs/util.js +22 -0
  352. package/time-picker/Picker.js +221 -0
  353. package/time-picker/RangePicker.js +56 -0
  354. package/time-picker/TimeColumn.js +65 -0
  355. package/time-picker/TimePicker.js +242 -0
  356. package/time-picker/context.js +5 -0
  357. package/time-picker/util.js +43 -0
  358. package/timeline/Item.js +94 -0
  359. package/timeline/Timeline.js +80 -0
  360. package/transfer/Item.js +107 -0
  361. package/transfer/List.js +192 -0
  362. package/tree/Animation.js +104 -0
  363. package/tree/Context.js +5 -0
  364. package/tree/Node.js +215 -0
  365. package/tree/NodeList.js +84 -0
  366. package/tree/Tree.js +549 -0
  367. package/tree/util.js +76 -0
  368. package/tree-select/List.js +127 -0
  369. package/tree-select/Select.js +260 -0
  370. package/tree-select/hook/useKeyCache.js +56 -0
  371. package/tree-select/hook/useStateValue.js +98 -0
  372. package/tree-select/hook/useTreeData.js +13 -0
  373. package/tree-select/interface.js +13 -0
  374. package/tree-select/util.js +9 -0
  375. package/trigger/Portal.js +14 -0
  376. package/trigger/getPopupStyle.js +190 -0
  377. package/types/badge/Count.d.ts +2 -1
  378. package/types/badge/index.d.ts +2 -2
  379. package/types/button/index.d.ts +2 -2
  380. package/types/carousel/index.d.ts +1 -1
  381. package/types/color-picker/colors.d.ts +1 -1
  382. package/types/color-picker/style/index.d.ts +1 -1
  383. package/types/drawer/Drawer.d.ts +1 -1
  384. package/types/dropdown/interface.d.ts +1 -0
  385. package/types/hooks/index.d.ts +122 -0
  386. package/types/hooks/use-verification-code/interface.d.ts +1 -1
  387. package/types/hooks/useAsync.d.ts +1 -1
  388. package/types/hooks/useDropArea.d.ts +1 -0
  389. package/types/hooks/useOverrideRef.d.ts +5 -0
  390. package/types/hooks/usePersistCallback.d.ts +1 -0
  391. package/types/hooks/useUpsert.d.ts +1 -1
  392. package/types/icon-hover/index.d.ts +5 -3
  393. package/types/index.d.ts +2 -120
  394. package/types/input-tag/InputTag.d.ts +1 -1
  395. package/types/link/interface.d.ts +1 -1
  396. package/types/list/index.d.ts +1 -1
  397. package/types/modal/interface.d.ts +1 -0
  398. package/types/notice/index.d.ts +3 -0
  399. package/types/notification/index.d.ts +1 -1
  400. package/types/page-header/index.d.ts +1 -1
  401. package/types/select/Select.d.ts +1 -1
  402. package/types/select-view/Core.d.ts +3 -2
  403. package/types/select-view/index.d.ts +1 -0
  404. package/types/statistic/index.d.ts +1 -1
  405. package/types/switch/index.d.ts +1 -1
  406. package/types/switch/interface.d.ts +1 -1
  407. package/types/table/interface.d.ts +2 -1
  408. package/types/tooltip/index.d.ts +1 -1
  409. package/types/trigger/index.d.ts +12 -8
  410. package/types/trigger/interface.d.ts +1 -0
  411. package/types/typography/Base.d.ts +8 -7
  412. package/types/typography/EditContent.d.ts +3 -2
  413. package/types/typography/Paragraph.d.ts +2 -5
  414. package/types/typography/Text.d.ts +1 -5
  415. package/types/typography/Title.d.ts +2 -5
  416. package/types/upload/TriggerNode.d.ts +5 -3
  417. package/types/upload/list/PictureItem.d.ts +3 -3
  418. package/types/upload/list/TextItem.d.ts +3 -3
  419. package/types/utils/CSSTransition.d.ts +2 -0
  420. package/types/utils/constant.d.ts +1 -1
  421. package/types/utils/is.d.ts +4 -0
  422. package/types/utils/reactDOM.d.ts +3 -1
  423. package/types/utils/warning.d.ts +1 -1
  424. package/types/version/index.d.ts +1 -1
  425. package/typography/Base.js +184 -0
  426. package/typography/EditContent.js +49 -0
  427. package/typography/Ellipsis.js +293 -0
  428. package/typography/Operations.js +78 -0
  429. package/typography/Paragraph.js +26 -0
  430. package/typography/Text.js +11 -0
  431. package/typography/Title.js +12 -0
  432. package/typography/Typography.js +15 -0
  433. package/typography/useCssEllipsis.js +37 -0
  434. package/typography/useEllipsis.js +150 -0
  435. package/upload/TriggerNode.js +118 -0
  436. package/upload/Upload.js +205 -0
  437. package/upload/Uploader.js +205 -0
  438. package/upload/interface.js +9 -0
  439. package/upload/list/PictureItem.js +91 -0
  440. package/upload/list/TextItem.js +99 -0
  441. package/upload/list/UploadProgress.js +97 -0
  442. package/upload/list/index.js +120 -0
  443. package/upload/request.js +51 -0
  444. package/upload/util.js +61 -0
  445. package/utils/CSSTransition.js +27 -0
  446. package/utils/contextHolder.js +29 -4
  447. package/utils/getHighlightText.js +1 -2
  448. package/utils/is.js +81 -68
  449. package/utils/reactDOM.js +33 -22
  450. package/utils/style.js +1 -2
  451. package/utils/warning.js +7 -3
  452. package/verification-code/VerificationCode.js +83 -0
  453. package/virtual-list/Filler.js +31 -0
  454. package/virtual-list/VirtualList.js +378 -0
  455. package/virtual-list/util/algorithm.js +32 -0
  456. package/virtual-list/util/item.js +99 -0
  457. package/{chunk/BCEX3Acw.js → watermark/Watermark.js} +13 -11
  458. package/chunk/B1P8u7kB.js +0 -798
  459. package/chunk/B2ufZjjd.js +0 -1000
  460. package/chunk/B7QOJqps.js +0 -162
  461. package/chunk/BBz3S3zo.js +0 -966
  462. package/chunk/BGzBxiWE.js +0 -517
  463. package/chunk/BNRfcEHj.js +0 -984
  464. package/chunk/BSs6uXmc.js +0 -946
  465. package/chunk/BTjUAV8T.js +0 -277
  466. package/chunk/BYQeEcKe.js +0 -375
  467. package/chunk/Ba4UXIST.js +0 -605
  468. package/chunk/BfaXVcik.js +0 -271
  469. package/chunk/Bs11tCU6.js +0 -240
  470. package/chunk/C7FC7dzS.js +0 -516
  471. package/chunk/CLzbve11.js +0 -694
  472. package/chunk/CN4zXU4b.js +0 -877
  473. package/chunk/CYTPZUHD.js +0 -769
  474. package/chunk/CcCo_dK0.js +0 -335
  475. package/chunk/CoCXcpQd.js +0 -261
  476. package/chunk/D4yH4UKK.js +0 -80
  477. package/chunk/DiSLYN2-.js +0 -167
  478. package/chunk/Dr0iXIXO.js +0 -736
  479. package/chunk/G3-2uJao.js +0 -229
  480. package/chunk/RnTpOC5-.js +0 -1
  481. package/chunk/Z-mtdHUQ.js +0 -226
  482. package/chunk/ZISxNnaR.js +0 -165
  483. package/chunk/aPJXnDSb.js +0 -450
  484. package/chunk/i605JRmI.js +0 -232
  485. package/chunk/l0sNRNKZ.js +0 -1
  486. package/types/form/FormItemTip.d.ts +0 -8
  487. /package/{chunk/C6Kfwj0f.js → loading/style/index.less.js} +0 -0
  488. /package/{chunk/DP2rzg_V.js → suspense-fallback-test/style/index.less.js} +0 -0
  489. /package/{chunk/K6Dvbx-E.js → virtual-list/style/index.less.js} +0 -0
package/Form.js CHANGED
@@ -1,1420 +1,32 @@
1
- var Xe = Object.defineProperty;
2
- var Ze = (s, e, t) => e in s ? Xe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var u = (s, e, t) => (Ze(s, typeof e != "symbol" ? e + "" : e, t), t);
4
- import "./chunk/C6Kfwj0f.js";
5
- import "./chunk/DiSLYN2-.js";
6
- import { jsx as f, jsxs as B, Fragment as Re } from "react/jsx-runtime";
7
- import Ye from "@unicom-cloud/scroll-into-view-if-needed";
8
- import M from "lodash/isPlainObject";
9
- import Pe from "lodash/merge";
10
- import A, { createContext as oe, useRef as U, forwardRef as pe, useContext as L, useEffect as se, useImperativeHandle as Ke, Component as et, isValidElement as me, useState as le, useMemo as we, cloneElement as Ee, createElement as tt, useCallback as Y } from "react";
11
- import { a as Se, b as rt } from "./chunk/Dr0iXIXO.js";
12
- import st from "./hooks/useCreate.js";
13
- import it from "./hooks/useMergeProps.js";
14
- import j from "@unicom-cloud/utils/class-name";
15
- import xe from "./utils/omit.js";
16
- import { NOOP as b } from "./utils/constant.js";
17
- import W from "lodash/get";
18
- import Me from "lodash/has";
19
- import E from "lodash/isArray";
20
- import O from "lodash/isFunction";
21
- import nt from "lodash/omit";
22
- import _e from "lodash/setWith";
23
- import { isExist as Te } from "./utils/is.js";
24
- import { Schema as lt } from "@unicom-cloud/utils/validate";
25
- import Le from "lodash/cloneDeepWith";
26
- import Ue from "lodash/set";
27
- import ot from "@unicom-cloud/icons/IconUiCheckCircleFill";
28
- import at from "@unicom-cloud/icons/IconUiCloseCircleFill";
29
- import ct from "@unicom-cloud/icons/IconUiExclamationCircleFill";
30
- import ut from "@unicom-cloud/icons/IconUiLoading";
31
- import dt from "lodash/isBoolean";
32
- import Fe from "lodash/isEqualWith";
33
- import ht from "lodash/isNil";
34
- import ee from "./utils/warning.js";
35
- import gt from "lodash/isObject";
36
- import K from "lodash/isUndefined";
37
- import De from "./Grid.js";
38
- import { CSSTransition as mt } from "@unicom-cloud/react-transition-group";
39
- import Ft from "@unicom-cloud/icons/IconUiQuestionCircleFill";
40
- import ft from "./Tooltip.js";
41
- import pt from "./hooks/useForceUpdate.js";
42
- import St from "lodash/isString";
43
- const H = oe({
44
- layout: "horizontal",
45
- labelCol: { span: 5, offset: 0 },
46
- labelAlign: "right",
47
- wrapperCol: { span: 19, offset: 0 },
48
- requiredSymbol: !0,
49
- getFormElementId: () => "pqb-",
50
- store: {
51
- clearFields: b,
52
- getFieldsValue: b,
53
- getFieldValue: b,
54
- getFieldError: b,
55
- getFieldsError: b,
56
- getTouchedFields: b,
57
- getFields: b,
58
- getInitialValues: b,
59
- setInitialValues: b,
60
- setInitialValue: b,
61
- setFieldValue: b,
62
- setFieldsValue: b,
63
- setFields: b,
64
- resetFields: b,
65
- submit: b,
66
- validate: b,
67
- getFieldsState: b,
68
- scrollToField: b,
69
- getInnerMethods: () => ({
70
- registerField: b,
71
- innerGetStore: b,
72
- registerStateWatcher: b,
73
- registerWatcher: b,
74
- innerGetStoreStatus: b
75
- })
76
- }
77
- }), fe = oe({}), Oe = oe({}), je = oe({}), he = {
78
- error: "error",
79
- success: "success",
80
- warning: "warning",
81
- validating: "validating"
82
- };
83
- var D = /* @__PURE__ */ ((s) => (s.init = "init", s.error = "error", s.success = "success", s.submitting = "submitting", s))(D || {});
84
- class Vt extends Error {
85
- constructor(t) {
86
- super("form validate error, get errors by error.errors");
87
- u(this, "errors", {});
88
- this.errors = t;
89
- }
90
- }
91
- function bt(s) {
92
- return Object.defineProperty(
93
- (...e) => typeof e[e.length - 1] == "function" ? s.apply(this, e) : new Promise((t, r) => (e[e.length] = (i, l) => {
94
- if (i)
95
- return r(new Vt(i));
96
- t(l);
97
- }, e.length++, s.apply(this, e))),
98
- "name",
99
- { value: s.name }
100
- );
101
- }
102
- function Z(s) {
103
- return Le(s, (e) => {
104
- if (!M(e) && !E(e))
105
- return e;
106
- });
107
- }
108
- const vt = (s, e) => Le(s, (t) => {
109
- if (O(t))
110
- return (r) => t(r, e);
111
- });
112
- function P(s, e, t) {
113
- return Ue(s, e, Z(t)), s;
114
- }
115
- function $e(s, e = "") {
116
- const t = /* @__PURE__ */ new Set(), r = (i, l = "") => i ? t.has(i) ? [] : (t.add(i), Object.keys(i).map((n) => (M(i[n]) || E(i[n])) && Object.keys(i[n]).length && !A.isValidElement(i[n]) ? r(i[n], `${l + n}.`) : l + n).flat()) : [];
117
- return r(s, e);
118
- }
119
- function Ge(s) {
120
- var e;
121
- return ((e = s == null ? void 0 : s.constructor) == null ? void 0 : e.name) === "SyntheticEvent" || (s == null ? void 0 : s.nativeEvent) instanceof Event;
122
- }
123
- async function ke(s, e, t, r) {
124
- const i = [...t || []];
125
- let l = 0;
126
- return new Promise(async (n) => {
127
- const o = [], c = async (h) => {
128
- const a = () => l < i.length - 1 ? (l++, c(i[l])) : n({ error: null, warning: o });
129
- if (!h)
130
- return a();
131
- const d = { ...h };
132
- !d.type && !d.validator && (d.type = "string"), new lt({ [s]: [d] }, {
133
- ignoreEmptyString: !0,
134
- validateMessages: r
135
- }).validate({ [s]: e }, (F) => {
136
- if (F)
137
- if (h.validateLevel === "warning")
138
- o.push(F[s].message);
139
- else
140
- return n({
141
- error: F,
142
- warning: o
143
- });
144
- return a();
145
- });
146
- };
147
- c(i[l]);
148
- });
149
- }
150
- function ne(s, e) {
151
- const t = _e({}, s, void 0, Object);
152
- return e.some((r) => Me(t, r));
153
- }
154
- const Ve = "_input";
155
- class yt {
156
- constructor() {
157
- // 表示的 Form 的提交状态而非单个字段的提交状态。
158
- // 只有在触发表单 reset(原生 reset,而非当前的 resetFields) 时,才会回到 init 状态(目前没有支持 form.reset,所以没有这块逻辑)
159
- u(this, "submitStatus", D.init);
160
- u(this, "registerFields", []);
161
- // 所有 form item value 的变动,都会通知这里注册到的 watcher
162
- u(this, "registerWatchers", []);
163
- // 所有 form item 内部 errors, validating, touched 状态的变化,都会通知这里注册到的 watcher
164
- // TODO: 合并 registerWatchers
165
- u(this, "registerStateWatchers", []);
166
- // 所有 form 整体 的变动,都会通知这里注册到的 watcher
167
- u(this, "registerFormWatchers", []);
168
- // 和formControl 的 touched属性不一样。 只要被改过的字段,这里就会存储。并且不会跟随formControl被卸载而清除。
169
- // reset 的时候清除
170
- u(this, "touchedFields", {});
171
- u(this, "store", {});
172
- u(this, "initialValues", {});
173
- u(this, "callbacks", {});
174
- // 告知 form 状态改变,进行状态收集
175
- u(this, "innerCollectFormState", () => {
176
- this.notifyStateWatchers();
177
- });
178
- u(this, "innerSetCallbacks", (e) => {
179
- this.callbacks = e;
180
- });
181
- u(this, "registerFormWatcher", (e) => (this.registerFormWatchers.push(e), () => {
182
- this.registerFormWatchers = this.registerFormWatchers.filter(
183
- (t) => t !== e
184
- );
185
- }));
186
- u(this, "registerStateWatcher", (e) => (this.registerStateWatchers.push(e), () => {
187
- this.registerStateWatchers = this.registerStateWatchers.filter(
188
- (t) => t !== e
189
- );
190
- }));
191
- u(this, "registerWatcher", (e) => (this.registerWatchers.push(e), () => {
192
- this.registerWatchers = this.registerWatchers.filter((t) => t !== e);
193
- }));
194
- // 收集所有control字段,并在组件卸载时移除
195
- u(this, "registerField", (e) => (this.registerFields.push(e), this.notifyWatchers(), () => {
196
- this.registerFields = this.registerFields.filter((t) => t !== e), this.notifyWatchers();
197
- }));
198
- // hasField为true时,只返回传入field属性的control实例
199
- // isFormList 目前只在校验时需要包含
200
- // TODO formlist 实现缺陷,待优化
201
- u(this, "getRegisteredFields", (e, t) => e ? this.registerFields.filter(
202
- (r) => {
203
- var i;
204
- return r.hasFieldProps() && ((t == null ? void 0 : t.containFormList) || !((i = r.props) != null && i.isFormList));
205
- }
206
- ) : this.registerFields);
207
- // 获取props.field === field 的control组件。
208
- u(this, "getRegisteredField", (e) => this.registerFields.filter((t) => t.props.field === e)[0]);
209
- // 通知所有的FormItem进行更新。
210
- // setFieldValue: 外部调用setFieldsValue (setFieldValue等)方法触发更新
211
- // innerSetValue: 控件例如Input,通过onChange事件触发的更新
212
- // reset:重置
213
- u(this, "notify", (e, t) => {
214
- (e === "setFieldValue" || e === "innerSetValue" && !t.ignore) && this._pushTouchField(
215
- t.changeValues ? $e(t.changeValues) : this._getIterativelyKeysByField(t.field)
216
- ), this.registerFields.forEach((r) => {
217
- var i;
218
- (i = r == null ? void 0 : r.onStoreChange) == null || i.call(r, e, {
219
- ...t,
220
- current: this.store
221
- });
222
- });
223
- });
224
- u(this, "innerSetInitialValues", (e) => {
225
- e && (this.initialValues = Pe(this.initialValues, Z(e)), Object.keys(e).forEach((t) => {
226
- P(this.store, t, e[t]);
227
- }));
228
- });
229
- u(this, "innerSetInitialValue", (e, t) => {
230
- e && (this.initialValues[e] = t, this._inTouchFields(e) || P(this.store, e, W(this.initialValues, e)));
231
- });
232
- /**
233
- *
234
- * 内部使用,更新value,会同时触发onChange 和 onValuesChange
235
- * @options.isFormList 强制更新field对应的组件包括其子组件,form
236
- */
237
- u(this, "innerSetFieldValue", (e, t, r) => {
238
- if (!e)
239
- return;
240
- const i = this.getFields();
241
- P(this.store, e, t), this.triggerValuesChange({
242
- [e]: t
243
- }), this.triggerTouchChange({ [e]: t }), this.notify("innerSetValue", {
244
- prev: i,
245
- field: e,
246
- ...r,
247
- changeValues: { [e]: t }
248
- });
249
- });
250
- // 内部使用
251
- u(this, "innerGetStore", () => this.store);
252
- // 目前返回提交状态,后续统一维护 errors,warnings 后,这里可进行拓展
253
- u(this, "innerGetStoreStatus", () => ({
254
- submitStatus: this.submitStatus
255
- }));
256
- // 内部使用,返回原始对象,注入到组件的 value 都从这里获取值,cloneDeep 后的值每次引用地址是不同的
257
- u(this, "innerGetFieldValue", (e) => W(this.store, e));
258
- // 获取所有被操作过的字段
259
- u(this, "getTouchedFields", () => this.getRegisteredFields(!0).filter((e) => e.isTouched()).map((e) => e.props.field));
260
- // 外部调用设置表单字段值
261
- u(this, "setFieldValue", (e, t) => {
262
- e && this.setFields({
263
- [e]: { value: t }
264
- });
265
- });
266
- // 外部调用,设置多个表单控件的值
267
- u(this, "setFieldsValue", (e) => {
268
- if (M(e)) {
269
- const t = Object.keys(e), r = {};
270
- t.forEach((i) => {
271
- r[i] = {
272
- value: e[i]
273
- };
274
- }), this.setFields(r);
275
- }
276
- });
277
- // 外部调用,设置多个表单控件的值,以及 error,touch 信息。
278
- u(this, "setFields", (e) => {
279
- const t = Object.keys(e), r = {};
280
- t.forEach((i) => {
281
- const l = e[i], n = this.getFields();
282
- if (l) {
283
- const o = {};
284
- "error" in l && (o.errors = l.error), "warning" in l && (o.warnings = l.warning), "touched" in l && (o.touched = l.touched), "value" in l && (P(this.store, i, l.value), r[i] = l.value), this.notify("setFieldValue", {
285
- data: o,
286
- prev: n,
287
- field: i,
288
- changeValues: { [i]: l.value }
289
- });
290
- }
291
- }), this.triggerValuesChange(r);
292
- });
293
- u(this, "getFieldValue", (e) => Z(W(this.store, e)));
294
- // 获取单个字段的错误信息。
295
- u(this, "getFieldError", (e) => {
296
- const t = this.getRegisteredField(e);
297
- return t ? t.getErrors() : null;
298
- });
299
- // 获取传入字段/全部的错误信息
300
- u(this, "getFieldsError", (e) => {
301
- const t = {};
302
- return E(e) ? e.map((r) => {
303
- const i = this.getFieldError(r);
304
- i && (t[r] = i);
305
- }) : this.getRegisteredFields(!0, { containFormList: !0 }).forEach(
306
- (r) => {
307
- r.getErrors() && (t[r.props.field] = r.getErrors());
308
- }
309
- ), t;
310
- });
311
- u(this, "getFields", () => Z(this.store));
312
- u(this, "getFieldsValue", (e) => {
313
- const t = {};
314
- return E(e) ? (e.forEach((r) => {
315
- P(t, r, this.getFieldValue(r));
316
- }), t) : (this.getRegisteredFields(!0).forEach(({ props: { field: r } }) => {
317
- const i = W(this.store, r);
318
- P(t, r, i);
319
- }), t);
320
- });
321
- u(this, "getInitialValues", () => this.initialValues);
322
- u(this, "setInitialValues", (e) => {
323
- this.innerSetInitialValues(e), this.setFieldsValue(e);
324
- });
325
- u(this, "setInitialValue", (e, t) => {
326
- this.innerSetInitialValue(e, t), this.setFieldValue(e, t);
327
- });
328
- u(this, "resetFields", (e) => {
329
- const t = this.getFields(), r = Te(e) && !E(e) ? [e] : e;
330
- let i = {};
331
- if (r && E(r))
332
- r.forEach((n) => {
333
- P(
334
- this.store,
335
- n,
336
- this.initialValues[n]
337
- ), i[n] = W(this.store, n);
338
- }), this.triggerValuesChange(i), this.notify("reset", { prev: t, field: r }), this._popTouchField(r);
339
- else {
340
- const n = {};
341
- i = this.getFields(), Object.keys(this.initialValues).forEach((o) => {
342
- P(n, o, this.initialValues[o]);
343
- }), this.store = n, this.getRegisteredFields(!0).forEach((o) => {
344
- const c = o.props.field;
345
- P(i, c, W(this.store, c));
346
- }), this.triggerValuesChange(i), this._popTouchField(), this.notify("reset", {
347
- prev: t,
348
- field: Object.keys(i)
349
- });
350
- }
351
- const { onReset: l } = this.callbacks;
352
- l == null || l(i);
353
- });
354
- u(this, "validate", bt(
355
- (e, t, r) => {
356
- const i = this.getRegisteredFields(!0, {
357
- containFormList: !0
358
- }), l = E(e) && e.length ? i.filter(
359
- (a) => e.indexOf(a.props.field) > -1
360
- ) : i, n = M(e) ? e : M(t) ? t : {}, o = O(e) ? e : O(t) ? t : r || (() => {
361
- }), c = l.map(
362
- (a) => n != null && n.validateOnly ? a.validateFieldOnly() : a.validateField()
363
- ), h = (a) => {
364
- if (!(n != null && n.validateOnly)) {
365
- const { onValidateFail: d } = this.callbacks;
366
- d == null || d(a);
367
- }
368
- };
369
- Promise.all(c).then((a) => {
370
- let d = {};
371
- const m = {};
372
- a.map((V) => {
373
- var S;
374
- V.error && (d = { ...d, ...V.error });
375
- const g = this.getRegisteredField(V.field);
376
- (S = g == null ? void 0 : g.props) != null && S.isFormList || P(m, V.field, V.value);
377
- });
378
- let F;
379
- return Object.keys(d).length ? (h == null || h(d), F = o == null ? void 0 : o(d, Z(m))) : F = o == null ? void 0 : o(null, Z(m)), F;
380
- });
381
- }
382
- ));
383
- u(this, "toggleSubmitStatus", (e) => {
384
- this.submitStatus = e, this.innerCollectFormState(), this.notifyFormWatcher();
385
- });
386
- u(this, "submit", () => (this.toggleSubmitStatus(D.submitting), this.validate((e, t) => {
387
- let r;
388
- const { onSubmit: i, onSubmitFailed: l } = this.callbacks;
389
- !e && i && (r = i(t)), e && l && (r = l(e)), r && r.then ? r.then((n) => (this.toggleSubmitStatus(D.success), n)).catch((n) => (this.toggleSubmitStatus(D.error), Promise.reject(n))) : this.toggleSubmitStatus(
390
- e ? D.error : D.success
391
- );
392
- })));
393
- u(this, "getFieldsState", (e) => {
394
- const t = {}, r = (i) => {
395
- if (!i)
396
- return null;
397
- const l = i.getErrors();
398
- return {
399
- errors: l ? [l] : [],
400
- warnings: i.getWarnings(),
401
- validateStatus: i.getValidateStatus(),
402
- isSubmitting: this.submitStatus === D.submitting,
403
- isTouched: i.isTouched(),
404
- value: this.getFieldValue(i.props.field)
405
- };
406
- };
407
- return E(e) ? (e.forEach((i) => {
408
- t[i] = r(this.getRegisteredField(i));
409
- }), t) : (this.getRegisteredFields(!0).forEach((i) => {
410
- t[i.props.field] = r(i);
411
- }), t);
412
- });
413
- u(this, "clearFields", (e) => {
414
- const t = this.getFields(), r = Te(e) && !E(e) ? [e] : e;
415
- if (r && E(r)) {
416
- const i = {};
417
- r.forEach((l) => {
418
- P(this.store, l, void 0), i[l] = W(this.store, l);
419
- }), this.triggerValuesChange(i), this.notify("setFieldValue", {
420
- prev: t,
421
- field: r,
422
- data: {
423
- errors: null,
424
- warnings: null
425
- }
426
- });
427
- } else {
428
- const i = {};
429
- this.store = {}, this.getRegisteredFields(!0).forEach((l) => {
430
- const n = l.props.field;
431
- P(i, n, void 0);
432
- }), this.triggerValuesChange(i), this.notify("setFieldValue", {
433
- prev: t,
434
- field: Object.keys(i),
435
- data: {
436
- errors: null,
437
- warnings: null
438
- }
439
- });
440
- }
441
- });
442
- }
443
- notifyWatchers() {
444
- this.registerWatchers.forEach((e) => {
445
- e();
446
- });
447
- }
448
- // 注册监听全局状态的 watcher
449
- notifyFormWatcher() {
450
- this.registerFormWatchers.forEach((e) => {
451
- e();
452
- });
453
- }
454
- notifyStateWatchers() {
455
- this.registerStateWatchers.forEach((e) => {
456
- e();
457
- });
458
- }
459
- triggerValuesChange(e) {
460
- if (e && Object.keys(e).length) {
461
- const { onValuesChange: t } = this.callbacks;
462
- t == null || t(e, this.getFields());
463
- }
464
- this.notifyWatchers();
465
- }
466
- triggerTouchChange(e) {
467
- if (e && Object.keys(e).length) {
468
- const { onChange: t } = this.callbacks;
469
- t == null || t(e, this.getFields());
470
- }
471
- }
472
- _getIterativelyKeysByField(e) {
473
- if (!e)
474
- return [];
475
- const r = [].concat(e).map((i) => $e(P({}, i, void 0))).reduce((i, l) => i.concat(l), []);
476
- return [e, ...r];
477
- }
478
- _inTouchFields(e) {
479
- return this._getIterativelyKeysByField(e).some((r) => Me(this.touchedFields, r));
480
- }
481
- _popTouchField(e) {
482
- e === void 0 && (this.touchedFields = {});
483
- const t = this._getIterativelyKeysByField(e);
484
- this.touchedFields = nt(this.touchedFields, t);
485
- }
486
- _pushTouchField(e) {
487
- [].concat(e).forEach((t) => {
488
- _e(this.touchedFields, t, void 0, Object);
489
- });
490
- }
491
- }
492
- function Ct() {
493
- const s = new yt();
494
- return {
495
- getFieldsValue: s.getFieldsValue,
496
- getFieldValue: s.getFieldValue,
497
- getFieldError: s.getFieldError,
498
- getFieldsError: s.getFieldsError,
499
- getTouchedFields: s.getTouchedFields,
500
- getFields: s.getFields,
501
- getInitialValues: s.getInitialValues,
502
- setInitialValues: s.setInitialValues,
503
- setInitialValue: s.setInitialValue,
504
- setFieldValue: s.setFieldValue,
505
- setFieldsValue: s.setFieldsValue,
506
- setFields: s.setFields,
507
- resetFields: s.resetFields,
508
- clearFields: s.clearFields,
509
- submit: s.submit,
510
- validate: s.validate,
511
- scrollToField: () => {
512
- },
513
- getFieldsState: s.getFieldsState,
514
- getInnerMethods: (e) => {
515
- const t = {};
516
- return e && [
517
- "registerField",
518
- "registerWatcher",
519
- "registerStateWatcher",
520
- "registerFormWatcher",
521
- "innerSetInitialValues",
522
- "innerSetInitialValue",
523
- "innerSetCallbacks",
524
- "innerSetFieldValue",
525
- "innerGetStore",
526
- "innerGetStoreStatus",
527
- "innerGetFieldValue",
528
- "innerCollectFormState"
529
- ].map((r) => {
530
- t[r] = s[r];
531
- }), t;
532
- }
533
- };
534
- }
535
- function qe(s) {
536
- const e = U(s);
537
- return e.current || (s ? e.current = s : e.current = Ct()), [e.current];
538
- }
539
- function ge(s, e) {
540
- const t = e.replace(/[[.]/g, "_").replace(/\]/g, "");
541
- return s ? `${s}-${t}` : `${t}`;
542
- }
543
- const It = {
544
- layout: "horizontal",
545
- labelCol: { span: 5, offset: 0 },
546
- labelAlign: "right",
547
- wrapperCol: { span: 19, offset: 0 },
548
- requiredSymbol: !0,
549
- wrapper: "form",
550
- validateTrigger: "onChange"
551
- }, wt = (s, e) => {
552
- var te, J;
553
- const t = L(Se), r = L(Oe), i = U(null), [l] = qe(
554
- s.form
555
- ), n = it(
556
- s,
557
- It,
558
- (te = t.componentConfig) == null ? void 0 : te.Form
559
- ), {
560
- layout: o,
561
- labelCol: c,
562
- wrapperCol: h,
563
- wrapper: a,
564
- id: d,
565
- requiredSymbol: m,
566
- labelAlign: F,
567
- disabled: V,
568
- colon: g,
569
- className: S,
570
- validateTrigger: v,
571
- prefixCls: I,
572
- validateMessages: w,
573
- ...T
574
- } = n, N = I || t.getPrefixCls("form"), ce = t.rtl, z = "size" in n ? n.size : t.size, ie = l.getInnerMethods(!0);
575
- st(() => {
576
- ie.innerSetInitialValues(n.initialValues);
577
- }), se(() => {
578
- let p;
579
- return r.register && (p = r.register(n.id, l)), p;
580
- }, [n.id, l]), Ke(e, () => l), l.scrollToField = (p, x) => {
581
- const $ = i.current, k = n.id;
582
- if (!$)
583
- return;
584
- let Q = $.querySelector(
585
- `#${ge(k, p)}`
586
- );
587
- Q || (Q = $.querySelector(
588
- `#${ge(k, p)}${Ve}`
589
- )), Q && Ye(Q, {
590
- behavior: "smooth",
591
- block: "nearest",
592
- scrollMode: "if-needed",
593
- ...x
594
- });
595
- }, ie.innerSetCallbacks({
596
- onValuesChange: (p, x) => {
597
- var $, k;
598
- ($ = n.onValuesChange) == null || $.call(n, p, x), (k = r.onFormValuesChange) == null || k.call(r, n.id, p);
599
- },
600
- onChange: n.onChange,
601
- onValidateFail: (p) => {
602
- if (n.scrollToFirstError) {
603
- const x = M(n.scrollToFirstError) ? n.scrollToFirstError : {};
604
- l.scrollToField(
605
- Object.keys(p)[0],
606
- x
607
- );
608
- }
609
- },
610
- onSubmitFailed: n.onSubmitFailed,
611
- onSubmit: (p) => {
612
- var $, k;
613
- const x = ($ = n.onSubmit) == null ? void 0 : $.call(n, p);
614
- return (k = r.onFormSubmit) == null || k.call(r, n.id, p), x;
615
- },
616
- onReset: (p) => {
617
- var $, k;
618
- const x = ($ = n.onReset) == null ? void 0 : $.call(n, p);
619
- return (k = r == null ? void 0 : r.onFormReset) == null || k.call(r, n.id, p), x;
620
- }
621
- });
622
- const ue = {
623
- requiredSymbol: m,
624
- labelAlign: F,
625
- disabled: V,
626
- colon: g,
627
- labelCol: c,
628
- wrapperCol: h,
629
- layout: o,
630
- store: l,
631
- prefixCls: N,
632
- validateTrigger: v,
633
- validateMessages: Pe(
634
- {},
635
- (J = t.locale.Form) == null ? void 0 : J.validateMessages,
636
- w
637
- ),
638
- getFormElementId: (p) => ge(d, p)
639
- };
640
- return /* @__PURE__ */ f(rt, { ...t, size: z, children: /* @__PURE__ */ f(H.Provider, { value: ue, children: /* @__PURE__ */ f(
641
- a,
642
- {
643
- ref: i,
644
- ...xe(T, [
645
- "form",
646
- "size",
647
- "initialValues",
648
- "onValuesChange",
649
- "onChange",
650
- "wrapperProps",
651
- "scrollToFirstError",
652
- "onSubmit",
653
- "onSubmitFailed",
654
- "onReset"
655
- ]),
656
- ...n.wrapperProps,
657
- className: j(
658
- N,
659
- `${N}-${o}`,
660
- `${N}-size-${z}`,
661
- { [`${N}-rtl`]: ce },
662
- S
663
- ),
664
- style: n.style,
665
- onSubmit: (p) => {
666
- p.preventDefault(), p.stopPropagation(), l.submit();
667
- },
668
- onReset: (p) => {
669
- p.preventDefault(), p.stopPropagation(), l.resetFields();
670
- },
671
- id: d,
672
- children: n.children
673
- }
674
- ) }) });
675
- }, ze = pe(wt);
676
- ze.displayName = "Form";
677
- class G extends et {
678
- constructor(t, r) {
679
- var i, l;
680
- super(t);
681
- u(this, "context");
682
- // 校验信息
683
- u(this, "errors", null);
684
- // 校验 warning 信息
685
- u(this, "warnings", null);
686
- // undefined => validating => success / error => (validating or undefined)
687
- u(this, "validateStatus");
688
- // 是否被用户操作过
689
- u(this, "touched");
690
- u(this, "isDestroyed", !1);
691
- // 保存 props.children 或函数类型 props.children() 的返回值
692
- u(this, "childrenElement", null);
693
- u(this, "removeRegisterField");
694
- // 触发 store 进行状态收集
695
- // TODO: error, validateStatus ,touched 状态和 UI 组件解耦,统一维护在 store 内部
696
- u(this, "triggerStateCollect", () => {
697
- const { innerCollectFormState: t } = this.context.store.getInnerMethods(!0);
698
- t();
699
- });
700
- // 切换校验状态
701
- u(this, "toggleValidateStatus", (t) => {
702
- this.validateStatus = t, this.triggerStateCollect();
703
- });
704
- // 切换 touch 状态
705
- u(this, "toggleTouched", (t) => {
706
- this.touched = dt(t) ? t : !this.touched, this.triggerStateCollect();
707
- });
708
- u(this, "setWarnings", (t) => {
709
- this.warnings = t, this.triggerStateCollect();
710
- });
711
- u(this, "setErrors", (t) => {
712
- this.errors = t, this.triggerStateCollect();
713
- });
714
- u(this, "getErrors", () => this.errors);
715
- u(this, "getWarnings", () => this.warnings || []);
716
- u(this, "isTouched", () => this.touched);
717
- u(this, "getValidateStatus", () => this.props.validateStatus ? this.props.validateStatus : this.validateStatus);
718
- u(this, "hasFieldProps", () => !!this.props.field);
719
- u(this, "clearFormItemError", (t = this.props.field) => {
720
- const { updateFormItem: r } = this.context;
721
- r == null || r(t, { errors: null, warnings: null });
722
- });
723
- u(this, "updateFormItem", () => {
724
- if (this.isDestroyed)
725
- return;
726
- this.forceUpdate();
727
- const { updateFormItem: t } = this.context;
728
- t == null || t(this.props.field, {
729
- errors: this.errors,
730
- warnings: this.warnings
731
- });
732
- });
733
- u(this, "getFieldValue", () => {
734
- const t = this.props.field, r = this.context.store;
735
- return t ? r.getInnerMethods(!0).innerGetFieldValue(t) : void 0;
736
- });
737
- u(this, "onStoreChange", (t, r) => {
738
- const i = E(r.field) ? r.field : [r.field], { field: l, shouldUpdate: n, dependencies: o } = this.props, c = (h) => {
739
- if (o && n && ee(!0, "`shouldUpdate` of the `Form.Item` will be ignored."), o)
740
- (E(o) || o.some(
741
- (a) => ne(a, i)
742
- )) && this.isTouched() && this.validateField();
743
- else if (n) {
744
- let a = !1;
745
- O(n) ? a = n(r.prev, r.current, {
746
- field: r.field,
747
- ...h
748
- }) : a = !Fe(r.prev, r.current), a && this.updateFormItem();
749
- }
750
- };
751
- switch (t) {
752
- case "reset":
753
- this.toggleTouched(!1), this.toggleValidateStatus(void 0), this.setErrors(null), this.setWarnings(null), o || n ? c() : this.updateFormItem();
754
- break;
755
- case "innerSetValue":
756
- if (ne(l, i)) {
757
- this.toggleTouched(!0), this.updateFormItem();
758
- return;
759
- }
760
- c({
761
- isInner: !0,
762
- isFormList: r.isFormList
763
- });
764
- break;
765
- case "setFieldValue":
766
- if (ne(l, i)) {
767
- this.toggleTouched(!0), r.data && "touched" in r.data && this.toggleTouched(r.data.touched), r.data && "warnings" in r.data && this.setWarnings(
768
- ht(r.data.warnings) ? [] : [].concat(r.data.warnings)
769
- ), r.data && "errors" in r.data ? this.setErrors(r.data.errors) : Fe(W(r.prev, l), W(r.current, l)) || this.setErrors(null), this.updateFormItem();
770
- return;
771
- }
772
- c();
773
- break;
774
- }
775
- });
776
- u(this, "innerSetFieldValue", (t, r) => {
777
- var o, c;
778
- if (!t)
779
- return;
780
- const { store: i } = this.context;
781
- i.getInnerMethods(!0).innerSetFieldValue(t, r);
782
- const n = {};
783
- Ue(n, t, r), (c = (o = this.props) == null ? void 0 : o.onValuesChange) == null || c.call(o, n, {
784
- ...i.getFieldsValue()
785
- });
786
- });
787
- // 仅仅校验下值,不做任何状态变更
788
- u(this, "validateFieldOnly", () => {
789
- const { validateMessages: t } = this.context, { field: r, rules: i } = this.props, l = this.getFieldValue();
790
- return ke(r, l, i, t).then(
791
- ({ error: n, warning: o }) => Promise.resolve({ error: n, value: l, warning: o, field: r })
792
- );
793
- });
794
- /**
795
- *
796
- * @param triggerType the value of validateTrigger.
797
- * @returns
798
- */
799
- u(this, "validateField", (t) => {
800
- const { validateTrigger: r, validateMessages: i } = this.context, { field: l, rules: n, validateTrigger: o } = this.props, c = this.getFieldValue(), h = () => {
801
- var m;
802
- const d = this.errors || ((m = this.warnings) == null ? void 0 : m.length);
803
- this.toggleValidateStatus("validating"), this.setErrors(null), this.setWarnings(null), d && this.updateFormItem();
804
- }, a = t ? (n || []).filter((d) => [].concat(
805
- d.validateTrigger || o || r
806
- ).indexOf(t) > -1) : n;
807
- return a && a.length && l ? (h(), ke(l, c, a, i).then(
808
- ({ error: d, warning: m }) => {
809
- var F;
810
- return this.setErrors(d ? d[l] : null), this.setWarnings(m || null), this.toggleValidateStatus(
811
- this.errors ? "error" : (F = this.warnings) != null && F.length ? "warning" : "success"
812
- ), this.updateFormItem(), Promise.resolve({ error: d, value: c, field: l });
813
- }
814
- )) : (h(), Promise.resolve({ error: null, value: c, field: l }));
815
- });
816
- // 每次 render 都会作为 onChange 传递给 children,需要保证引用地址不变
817
- // 所以 handleTrigger 需要声明在类上,并且直接作为 children.props.onChange
818
- u(this, "handleTrigger", (t, ...r) => {
819
- const i = this.childrenElement || this.props.children, { store: l } = this.context, { field: n, trigger: o, normalize: c, getValueFromEvent: h } = this.props, a = O(h) ? h(t, ...r) : t;
820
- let d = a;
821
- if (Ge(a)) {
822
- ee(
823
- !0,
824
- "changed value missed, please check whether extra elements is outta input/select controled by Form.Item"
825
- ), a.stopPropagation();
826
- return;
827
- }
828
- typeof c == "function" && (d = c(a, l.getFieldValue(n), {
829
- ...l.getFieldsValue()
830
- })), this.toggleTouched(!0), this.innerSetFieldValue(n, d), this.validateField(o), me(i) && i.props && i.props[o] && (this.props.isFormList || i.props[o](d, ...r));
831
- });
832
- u(this, "getChild", () => {
833
- const { children: t } = this.props, { store: r } = this.context;
834
- let i = t;
835
- return O(t) && (i = t(
836
- r.getFields(),
837
- {
838
- ...r
839
- },
840
- this.props.isFormList && {
841
- value: this.getFieldValue(),
842
- onChange: this.handleTrigger
843
- }
844
- )), this.childrenElement = i, i;
845
- });
846
- "initialValue" in t && this.hasFieldProps() && ((l = (i = r == null ? void 0 : r.store) == null ? void 0 : i.setInitialValue) == null || l.call(i, t.field, t.initialValue));
847
- }
848
- componentDidMount() {
849
- const { store: t } = this.context ?? {};
850
- if (t) {
851
- const r = t.getInnerMethods(!0);
852
- this.removeRegisterField = r.registerField(this);
853
- }
854
- this.isDestroyed = !1;
855
- }
856
- componentDidUpdate(t) {
857
- (t.field !== this.props.field && this.props._key && t._key === this.props._key || /* 以下条件判断潘启宝添加于 2023年10月23日 星期一 13时10分43秒 CST */
858
- this.props.disabled !== t.disabled && this.props.disabled || this.props.rules !== t.rules && !this.props.rules) && (this.updateFormItem(), this.clearFormItemError(t.field));
859
- }
860
- componentWillUnmount() {
861
- var t;
862
- (t = this.removeRegisterField) == null || t.call(this), this.removeRegisterField = null, this.clearFormItemError(), this.isDestroyed = !0;
863
- }
864
- /**
865
- * 收集rules里的validateTrigger字段
866
- */
867
- getValidateTrigger() {
868
- const t = this.props.validateTrigger || this.context.validateTrigger || "onChange", r = this.props.rules || [];
869
- let i = [];
870
- return r.map((l) => {
871
- i = i.concat(l.validateTrigger || t);
872
- }), Array.from(new Set(i));
873
- }
874
- renderControl(t, r) {
875
- var g;
876
- const {
877
- field: i,
878
- trigger: l = "onChange",
879
- triggerPropName: n = "value",
880
- validateStatus: o,
881
- formatter: c
882
- } = this.props, { store: h, disabled: a } = this.context, d = "disabled" in this.props ? this.props.disabled : a, m = A.Children.only(t), F = {
883
- // used by label
884
- id: j(((g = m.props) == null ? void 0 : g.id) || { [`${r}${Ve}`]: r })
885
- };
886
- this.getValidateTrigger().forEach((S) => {
887
- F[S] = (v) => {
888
- var I, w;
889
- this.validateField(S), (w = (I = m.props) == null ? void 0 : I[S]) == null || w.call(I, v);
890
- };
891
- }), F[l] = this.handleTrigger, d !== void 0 && !("disabled" in m.props) && (F.disabled = d);
892
- let V = W(h.getInnerMethods(!0).innerGetStore(), i);
893
- return O(c) && (V = c(V)), F[n] = V, !o && this.errors && (F.error = !0), A.cloneElement(m, F);
894
- }
895
- render() {
896
- const { noStyle: t, field: r, isFormList: i, hasFeedback: l } = this.props, n = this.getValidateStatus(), { prefixCls: o, getFormElementId: c } = this.context;
897
- let h = this.getChild();
898
- const a = this.hasFieldProps() ? c == null ? void 0 : c(r) : void 0;
899
- return this.hasFieldProps() && !i && A.Children.count(h) === 1 && (h = this.renderControl(h, a)), t ? h : /* @__PURE__ */ f("div", { className: `${o}-item-control-wrapper`, children: /* @__PURE__ */ f("div", { className: `${o}-item-control`, id: a, children: /* @__PURE__ */ B("div", { className: `${o}-item-control-children`, children: [
900
- h,
901
- n && l && /* @__PURE__ */ B(
902
- "div",
903
- {
904
- className: `${o}-item-feedback ${o}-item-feedback-${n}`,
905
- children: [
906
- n === "warning" && /* @__PURE__ */ f(ct, {}),
907
- n === "success" && /* @__PURE__ */ f(ot, {}),
908
- n === "error" && /* @__PURE__ */ f(at, {}),
909
- n === "validating" && /* @__PURE__ */ f(ut, {})
910
- ]
911
- }
912
- )
913
- ] }) }) });
914
- }
915
- }
916
- u(G, "defaultProps", {
917
- trigger: "onChange",
918
- triggerPropName: "value"
919
- }), u(G, "isFormControl", !0), u(G, "contextType", fe);
920
- const Et = ({
921
- prefixCls: s,
922
- help: e,
923
- errors: t = [],
924
- warnings: r = []
925
- }) => {
926
- const i = L(H), { getPrefixCls: l } = L(Se), n = s || i.prefixCls || l("form"), o = t == null ? void 0 : t.map((d, m) => {
927
- if (d)
928
- return /* @__PURE__ */ f("div", { role: "alert", children: d.message }, m);
929
- }), c = [];
930
- r == null || r.map((d, m) => {
931
- c.push(
932
- /* @__PURE__ */ f(
933
- "div",
934
- {
935
- role: "alert",
936
- className: `${n}-message-help-warning`,
937
- children: d
938
- },
939
- m
940
- )
941
- );
942
- });
943
- const h = !K(e) || !!c.length, a = h || !!o.length;
944
- return a && /* @__PURE__ */ f(
945
- mt,
946
- {
947
- in: a,
948
- appear: !0,
949
- classNames: "formblink",
950
- timeout: 300,
951
- unmountOnExit: !0,
952
- children: /* @__PURE__ */ f(
953
- "div",
954
- {
955
- className: j(`${n}-message`, {
956
- [`${n}-message-help`]: h
957
- }),
958
- children: K(e) ? /* @__PURE__ */ B(Re, { children: [
959
- o.length > 0 && o,
960
- c.length > 0 && c
961
- ] }) : e
962
- }
963
- )
964
- }
965
- );
966
- };
967
- function Tt(s) {
968
- return /* @__PURE__ */ f(
969
- "svg",
970
- {
971
- width: "1em",
972
- height: "1em",
973
- "aria-hidden": !0,
974
- focusable: !1,
975
- fill: "currentColor",
976
- stroke: "none",
977
- viewBox: "0 0 48 48",
978
- ...s,
979
- children: /* @__PURE__ */ f("path", { d: "M30.841,46.115l5.864,-2.824l-6.841,-14.205l15.371,3.508l1.449,-6.345l-15.372,-3.509l12.327,-9.83l-4.058,-5.088l-12.327,9.83l0,-15.767l-6.508,0l-0,15.767l-12.327,-9.83l-4.058,5.088l12.327,9.83l-15.372,3.509l1.449,6.345l15.371,-3.508l-6.841,14.205l5.864,2.824l6.841,-14.206l6.841,14.206Z" })
980
- }
981
- );
982
- }
983
- const $t = ({
984
- htmlFor: s,
985
- showColon: e,
986
- label: t,
987
- requiredSymbol: r,
988
- required: i,
989
- rules: l,
990
- prefix: n,
991
- tooltip: o
992
- }) => {
993
- const c = E(l) && l.some((m) => m && m.required), h = M(r) ? r.position : "end", a = (i || c) && !!r && /* @__PURE__ */ f("strong", { className: `${n}-form-item-symbol`, children: /* @__PURE__ */ f(Tt, {}) }), d = () => {
994
- if (!o)
995
- return null;
996
- const m = `${n}-form-item-tooltip`;
997
- let F = {}, V = /* @__PURE__ */ f(Ft, { className: m });
998
- if (!M(o) || me(o))
999
- F = {
1000
- content: o
1001
- };
1002
- else {
1003
- const { icon: g, ...S } = o;
1004
- F = S, g && (V = me(g) ? A.cloneElement(g, {
1005
- className: j(
1006
- m,
1007
- g.props.className
1008
- )
1009
- }) : g);
1010
- }
1011
- return /* @__PURE__ */ f(ft, { ...F, children: V });
1012
- };
1013
- return t ? /* @__PURE__ */ B("label", { htmlFor: s && `${s}${Ve}`, children: [
1014
- h !== "end" && a,
1015
- " ",
1016
- t,
1017
- d(),
1018
- h === "end" && /* @__PURE__ */ B(Re, { children: [
1019
- " ",
1020
- a
1021
- ] }),
1022
- e ? e === !0 ? ":" : e : ""
1023
- ] }) : null;
1024
- }, kt = De.Row, We = De.Col, Wt = (s, e) => {
1025
- var ve, ye, Ce;
1026
- const { getPrefixCls: t, prefixCls: r } = L(Se), i = L(fe), l = L(je), [n, o] = le(null), [c, h] = le(null), a = L(H), d = a.prefixCls || t("form"), m = s.layout || a.layout, F = s.labelAlign || a.labelAlign, V = U(!1), g = "disabled" in s ? s.disabled : a.disabled, S = (R, C = {}) => {
1027
- if (V.current)
1028
- return;
1029
- const { errors: re, warnings: X } = C || {};
1030
- o((_) => {
1031
- const y = { ..._ || {} };
1032
- return re ? y[R] = re : delete y[R], y;
1033
- }), h((_) => {
1034
- const y = { ..._ || {} };
1035
- return X && X.length ? y[R] = X : delete y[R], y;
1036
- });
1037
- }, v = gt(s.noStyle) && s.noStyle.showErrorTip && i.updateFormItem ? i.updateFormItem : S;
1038
- se(() => (V.current = !1, () => {
1039
- V.current = !0, o(null), h(null);
1040
- }), []);
1041
- const I = {
1042
- ...a,
1043
- validateMessages: a.validateMessages && vt(a.validateMessages, {
1044
- label: s.label
1045
- }),
1046
- prefixCls: d,
1047
- updateFormItem: v,
1048
- disabled: "disabled" in s ? s.disabled : a.disabled
1049
- }, { label: w, extra: T, className: N, style: ce, validateStatus: z, hidden: ie, ...ue } = s, be = j(`${d}-label-item`, {
1050
- [`${d}-label-item-left`]: F === "left"
1051
- }), te = n ? Object.values(n) : [], J = c ? Object.values(c).reduce((R, C) => R.concat(C), []) : [], p = we(() => {
1052
- if (z)
1053
- return z;
1054
- if (te.length)
1055
- return he.error;
1056
- if (J.length)
1057
- return he.warning;
1058
- }, [n, c, z]), x = we(() => !K(s.help) || J.length > 0, [s.help, c]), $ = j(
1059
- `${d}-item`,
1060
- {
1061
- [`${d}-item-error`]: x || !z && p === he.error,
1062
- [`${d}-item-status-${p}`]: p,
1063
- [`${d}-item-has-help`]: x,
1064
- [`${d}-item-hidden`]: ie,
1065
- [`${d}-item-has-feedback`]: p && s.hasFeedback
1066
- },
1067
- `${d}-layout-${m}`,
1068
- N
1069
- ), k = () => {
1070
- var re, X;
1071
- const { field: R, children: C } = s;
1072
- if (O(C))
1073
- return /* @__PURE__ */ f(
1074
- G,
1075
- {
1076
- disabled: g,
1077
- ...s,
1078
- ...R ? { key: R, _key: R } : {},
1079
- children: (..._) => C(
1080
- ..._
1081
- )
1082
- }
1083
- );
1084
- if (E(C)) {
1085
- const _ = A.Children.map(C, (y, He) => {
1086
- const Ie = M(y) && y.key || He, Je = M(y) && "disabled" in y.props, Qe = !K(g) && !Je ? { key: Ie, disabled: g } : { key: Ie };
1087
- return M(y) ? Ee(y, Qe) : y;
1088
- });
1089
- return /* @__PURE__ */ f(G, { ...s, field: void 0, children: _ });
1090
- }
1091
- if (A.Children.count(C) == 1) {
1092
- if (R) {
1093
- const _ = ((re = l == null ? void 0 : l.getItemKey) == null ? void 0 : re.call(l, R)) || R;
1094
- return /* @__PURE__ */ tt(G, { disabled: g, ...s, key: _, _key: _ }, C);
1095
- }
1096
- if (M(C)) {
1097
- if ((X = C.type) != null && X.isFormControl)
1098
- return C;
1099
- const y = !("disabled" in C.props) && !K(g) ? { disabled: g } : null;
1100
- return /* @__PURE__ */ f(G, { ...s, field: void 0, children: y ? Ee(C, y) : C });
1101
- }
1102
- }
1103
- return C;
1104
- }, Q = fe, de = {
1105
- ...a
1106
- };
1107
- return s.noStyle || (de.wrapperCol = void 0, de.labelCol = void 0), /* @__PURE__ */ f(H.Provider, { value: de, children: /* @__PURE__ */ f(Q.Provider, { value: I, children: s.noStyle ? k() : /* @__PURE__ */ B(
1108
- kt,
1109
- {
1110
- ref: e,
1111
- ...xe(ue, [
1112
- "tooltip",
1113
- "children",
1114
- "prefixCls",
1115
- "store",
1116
- "initialValue",
1117
- "field",
1118
- "labelCol",
1119
- "wrapperCol",
1120
- "colon",
1121
- "disabled",
1122
- "rules",
1123
- "trigger",
1124
- "triggerPropName",
1125
- "validateTrigger",
1126
- "noStyle",
1127
- "required",
1128
- "hasFeedback",
1129
- "help",
1130
- "normalize",
1131
- "formatter",
1132
- "getValueFromEvent",
1133
- "shouldUpdate",
1134
- "field",
1135
- "isInner",
1136
- "labelAlign",
1137
- "layout",
1138
- "requiredSymbol",
1139
- "isFormList"
1140
- ]),
1141
- className: $,
1142
- div: m !== "horizontal",
1143
- style: ce,
1144
- children: [
1145
- w ? /* @__PURE__ */ f(
1146
- We,
1147
- {
1148
- ...s.labelCol || a.labelCol,
1149
- className: j(
1150
- be,
1151
- (ve = s.labelCol) == null ? void 0 : ve.className,
1152
- (ye = a.labelCol) == null ? void 0 : ye.className,
1153
- {
1154
- [`${d}-label-item-flex`]: !s.labelCol && !a.labelCol
1155
- }
1156
- ),
1157
- children: /* @__PURE__ */ f(
1158
- $t,
1159
- {
1160
- tooltip: s.tooltip,
1161
- htmlFor: s.field && ((Ce = a == null ? void 0 : a.getFormElementId) == null ? void 0 : Ce.call(a, s.field)),
1162
- label: w,
1163
- prefix: r,
1164
- requiredSymbol: "requiredSymbol" in s ? s.requiredSymbol : a.requiredSymbol,
1165
- required: s.required,
1166
- rules: s.rules,
1167
- showColon: "colon" in s ? s.colon : a.colon
1168
- }
1169
- )
1170
- }
1171
- ) : null,
1172
- /* @__PURE__ */ B(
1173
- We,
1174
- {
1175
- className: j(`${d}-item-wrapper`, {
1176
- [`${d}-item-wrapper-flex`]: !s.wrapperCol && !a.wrapperCol
1177
- }),
1178
- ...s.wrapperCol || a.wrapperCol,
1179
- children: [
1180
- k(),
1181
- /* @__PURE__ */ f(
1182
- Et,
1183
- {
1184
- prefixCls: d,
1185
- help: s.help,
1186
- errors: te,
1187
- warnings: J
1188
- }
1189
- ),
1190
- T && /* @__PURE__ */ f("div", { className: `${d}-extra`, children: T })
1191
- ]
1192
- }
1193
- )
1194
- ]
1195
- }
1196
- ) }) });
1197
- }, ae = pe(Wt);
1198
- ae.defaultProps = {
1199
- trigger: "onChange",
1200
- triggerPropName: "value"
1201
- };
1202
- ae.displayName = "FormItem";
1203
- const Ne = (s, e) => !K(s) && s >= 0 && s < e.length, Ae = (s) => {
1204
- const { field: e, children: t, initialValue: r } = s, i = U({
1205
- id: 0,
1206
- keys: []
1207
- }), l = "initialValue" in s ? { initialValue: r } : {}, n = i.current.keys;
1208
- return /* @__PURE__ */ f(
1209
- je.Provider,
1210
- {
1211
- value: {
1212
- getItemKey: (o) => {
1213
- const c = o == null ? void 0 : o.replace(/\[|\]/g, ".").split("."), h = c.indexOf(e), a = c[h + 1];
1214
- return `${e}_${n.indexOf(a)}_${c.slice(h + 2).join("_")}`;
1215
- }
1216
- },
1217
- children: /* @__PURE__ */ f(
1218
- ae,
1219
- {
1220
- field: e,
1221
- ...l,
1222
- isFormList: !0,
1223
- rules: s.rules,
1224
- wrapperCol: { span: 24 },
1225
- noStyle: "noStyle" in s ? s.noStyle : !s.rules,
1226
- shouldUpdate: (o, c, h) => {
1227
- var a, d;
1228
- return !!(h && !h.isInner && ne(h.field, [e]) && ((a = W(o, e)) == null ? void 0 : a.length) !== ((d = W(c, e)) == null ? void 0 : d.length));
1229
- },
1230
- children: (o, c, { value: h, onChange: a }) => {
1231
- const d = h || [], m = function(g, S) {
1232
- var N;
1233
- if (Ge(g)) {
1234
- ee(
1235
- !0,
1236
- "Form.List: The event object cannot be used as a parameter of the add method"
1237
- );
1238
- return;
1239
- }
1240
- const v = ((N = c.getInnerMethods(!0)) == null ? void 0 : N.innerGetFieldValue(e)) || [], I = i.current.id;
1241
- i.current.id += 1;
1242
- const w = v || [];
1243
- let T = w;
1244
- S !== void 0 && S >= 0 && S <= w.length ? (n.splice(S, 0, I), T = [
1245
- ...w.slice(0, S),
1246
- g,
1247
- ...w.slice(S)
1248
- ]) : (n.push(I), T = [...w, g]), a(T, {
1249
- isFormList: !0,
1250
- ignore: g === void 0
1251
- });
1252
- }, F = function(g) {
1253
- var I;
1254
- const v = (((I = c.getInnerMethods(!0)) == null ? void 0 : I.innerGetFieldValue(e)) || []).filter((w, T) => T !== g);
1255
- n.splice(g, 1), a([...v], { isFormList: !0 });
1256
- }, V = function(g, S) {
1257
- var N;
1258
- const v = ((N = c.getInnerMethods(!0)) == null ? void 0 : N.innerGetFieldValue(e)) || [];
1259
- if (g === S || !Ne(g, v) || !Ne(S, v))
1260
- return;
1261
- const I = n[g];
1262
- n.splice(g, 1), n.splice(S, 0, I);
1263
- const w = v[g], T = [...v];
1264
- T.splice(g, 1), T.splice(S, 0, w), a(T, { isFormList: !0 });
1265
- };
1266
- return O(t) && t(
1267
- d.map((g, S) => {
1268
- let v = n[S];
1269
- return v === void 0 && (v = i.current.id, n.push(v), i.current.id += 1), {
1270
- field: `${e}[${S}]`,
1271
- key: v
1272
- };
1273
- }),
1274
- {
1275
- add: m,
1276
- remove: F,
1277
- move: V
1278
- }
1279
- );
1280
- }
1281
- }
1282
- )
1283
- }
1284
- );
1285
- };
1286
- Ae.displayName = "FormList";
1287
- const Nt = (s, e) => {
1288
- const t = U({}), r = Y((o, c) => (o && (t.current[o] = c), () => {
1289
- delete t.current[o];
1290
- }), []), i = Y(
1291
- (o, c) => {
1292
- var h;
1293
- (h = s.onFormSubmit) == null || h.call(s, o, c, {
1294
- forms: t.current
1295
- });
1296
- },
1297
- [s.onFormSubmit]
1298
- ), l = Y(
1299
- (o, c) => {
1300
- var h;
1301
- (h = s.onFormReset) == null || h.call(s, o, c, {
1302
- forms: t.current
1303
- });
1304
- },
1305
- [s.onFormReset]
1306
- ), n = Y(
1307
- (o, c) => {
1308
- var h;
1309
- (h = s.onFormValuesChange) == null || h.call(s, o, c, {
1310
- forms: t.current
1311
- });
1312
- },
1313
- [s.onFormValuesChange]
1314
- );
1315
- return /* @__PURE__ */ f(
1316
- Oe.Provider,
1317
- {
1318
- value: {
1319
- onFormValuesChange: n,
1320
- onFormSubmit: i,
1321
- onFormReset: l,
1322
- register: r
1323
- },
1324
- children: s.children
1325
- }
1326
- );
1327
- }, Be = pe(Nt);
1328
- Be.displayName = "FormProvider";
1329
- const Rt = () => {
1330
- const s = L(H), e = s.store, t = U(!1), r = pt(), i = Y(() => {
1331
- var o, c, h;
1332
- const { submitStatus: l } = ((h = (c = (o = e == null ? void 0 : e.getInnerMethods) == null ? void 0 : o.call(e, !0)) == null ? void 0 : c.innerGetStoreStatus) == null ? void 0 : h.call(c)) ?? {}, n = l === D.submitting;
1333
- n !== t.current && (t.current = n, r());
1334
- }, []);
1335
- return se(() => {
1336
- var c;
1337
- if (!e) {
1338
- ee(!0, "formInstance is not available");
1339
- return;
1340
- }
1341
- const { registerFormWatcher: l } = ((c = e == null ? void 0 : e.getInnerMethods) == null ? void 0 : c.call(e, !0)) ?? {}, n = () => i();
1342
- n();
1343
- const o = (l == null ? void 0 : l(n)) ?? {};
1344
- return () => {
1345
- o == null || o();
1346
- };
1347
- }, []), {
1348
- form: e,
1349
- disabled: s.disabled,
1350
- isSubmitting: t.current
1351
- };
1352
- }, Pt = (s, e) => {
1353
- const t = L(H), r = e || t.store, i = U(s);
1354
- i.current = s;
1355
- const l = Y(() => {
1356
- const h = i.current, a = r.getFieldsState([h]);
1357
- return a == null ? void 0 : a[h];
1358
- }, []), [n, o] = le(l), c = U(n);
1359
- return se(() => {
1360
- var m;
1361
- if (!r) {
1362
- ee(!0, "formInstance is not available");
1363
- return;
1364
- }
1365
- const { registerStateWatcher: h } = ((m = r == null ? void 0 : r.getInnerMethods) == null ? void 0 : m.call(r, !0)) ?? {}, a = () => {
1366
- const F = l();
1367
- Fe(c.current, F) || (o(F), c.current = F);
1368
- };
1369
- a();
1370
- const d = h == null ? void 0 : h(a);
1371
- return () => {
1372
- d == null || d();
1373
- };
1374
- }, []), n;
1375
- }, xt = (s, e) => {
1376
- const t = L(H), r = e || t.store, [i, l] = le(() => {
1377
- const c = r == null ? void 0 : r.getFieldsValue([].concat(s));
1378
- return St(s) ? W(c, s) : c;
1379
- }), n = U(s);
1380
- n.current = s;
1381
- const o = U(JSON.stringify(i));
1382
- return se(() => {
1383
- var d;
1384
- if (!r) {
1385
- ee(!0, "formInstance is not available");
1386
- return;
1387
- }
1388
- const { registerWatcher: c } = ((d = r == null ? void 0 : r.getInnerMethods) == null ? void 0 : d.call(r, !0)) ?? {}, h = () => {
1389
- const m = n.current, F = r.getFieldsValue([].concat(m));
1390
- let V = F;
1391
- E(m) || (V = W(F, m));
1392
- const g = JSON.stringify(V);
1393
- o.current !== g && (l(V), o.current = g);
1394
- };
1395
- h();
1396
- const a = c == null ? void 0 : c(h);
1397
- return () => {
1398
- a == null || a();
1399
- };
1400
- }, []), i;
1401
- }, q = ze;
1402
- q.Provider = Be;
1403
- q.Item = ae;
1404
- q.List = Ae;
1405
- q.Control = G;
1406
- q.useForm = qe;
1407
- q.useFormContext = Rt;
1408
- q.useWatch = xt;
1409
- q.useFormState = Pt;
1
+ /* empty css */
2
+ /* empty css */
3
+ /* empty css */
4
+ import r from "./form/Form.js";
5
+ import m from "./form/Control.js";
6
+ import t from "./form/FormItem.js";
7
+ import e from "./form/FormList.js";
8
+ import i from "./form/FormProvider.js";
9
+ import p from "./form/hook/useContext.js";
10
+ import s from "./form/hook/useState.js";
11
+ import F from "./form/hook/useWatch.js";
12
+ import f from "./form/useForm.js";
13
+ const o = r;
14
+ o.Provider = i;
15
+ o.Item = t;
16
+ o.List = e;
17
+ o.Control = m;
18
+ o.useForm = f;
19
+ o.useFormContext = p;
20
+ o.useWatch = F;
21
+ o.useFormState = s;
1410
22
  export {
1411
- G as FormControl,
1412
- ae as FormItem,
1413
- Ae as FormList,
1414
- Be as FormProvider,
1415
- q as default,
1416
- qe as useForm,
1417
- Rt as useFormContext,
1418
- Pt as useFormState,
1419
- xt as useWatch
23
+ m as FormControl,
24
+ t as FormItem,
25
+ e as FormList,
26
+ i as FormProvider,
27
+ o as default,
28
+ f as useForm,
29
+ p as useFormContext,
30
+ s as useFormState,
31
+ F as useWatch
1420
32
  };