rsuite 6.1.2 → 6.2.0

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 (651) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/Timeline/styles/index.css +11 -0
  3. package/Timeline/styles/index.scss +13 -0
  4. package/Uploader/styles/index.css +3 -0
  5. package/Uploader/styles/index.scss +3 -0
  6. package/cjs/Affix/Affix.js +4 -4
  7. package/cjs/Animation/Collapse.js +4 -5
  8. package/cjs/Animation/Transition.d.ts +2 -2
  9. package/cjs/Animation/Transition.js +17 -20
  10. package/cjs/AutoComplete/AutoComplete.d.ts +2 -0
  11. package/cjs/AutoComplete/AutoComplete.js +12 -10
  12. package/cjs/Avatar/useImage.js +1 -1
  13. package/cjs/AvatarGroup/AvatarGroup.d.ts +2 -2
  14. package/cjs/Badge/Badge.js +1 -4
  15. package/cjs/Breadcrumb/Breadcrumb.js +4 -4
  16. package/cjs/Button/Button.js +6 -6
  17. package/cjs/Calendar/Calendar.js +5 -5
  18. package/cjs/Calendar/CalendarBody.js +1 -1
  19. package/cjs/Calendar/CalendarContainer.js +14 -33
  20. package/cjs/Calendar/CalendarHeader.js +7 -8
  21. package/cjs/Calendar/Grid/GridCell.js +2 -2
  22. package/cjs/Calendar/Grid/GridHeaderRow.js +1 -1
  23. package/cjs/Calendar/Grid/GridRow.js +5 -6
  24. package/cjs/Calendar/MonthDropdown/MonthDropdown.js +1 -1
  25. package/cjs/Calendar/MonthDropdown/MonthDropdownItem.js +1 -1
  26. package/cjs/Calendar/TimeDropdown/TimeDropdown.js +12 -14
  27. package/cjs/Calendar/hooks/useCalendar.d.ts +16 -17
  28. package/cjs/Calendar/hooks/useCalendar.js +2 -4
  29. package/cjs/Calendar/hooks/useCalendarDate.js +5 -9
  30. package/cjs/Calendar/hooks/useCalendarState.js +6 -12
  31. package/cjs/Calendar/types.d.ts +0 -1
  32. package/cjs/Carousel/Carousel.js +5 -6
  33. package/cjs/CascadeTree/CascadeTree.js +6 -16
  34. package/cjs/CascadeTree/TreeView.js +5 -7
  35. package/cjs/CascadeTree/hooks/useSearch.d.ts +0 -1
  36. package/cjs/CascadeTree/hooks/useSearch.js +1 -1
  37. package/cjs/CascadeTree/hooks/useSelect.d.ts +0 -1
  38. package/cjs/CascadeTree/hooks/useSelect.js +3 -4
  39. package/cjs/CascadeTree/types.d.ts +0 -1
  40. package/cjs/CascadeTree/utils.js +1 -2
  41. package/cjs/Cascader/Cascader.js +18 -29
  42. package/cjs/Cascader/useActive.d.ts +0 -1
  43. package/cjs/Cascader/useActive.js +4 -6
  44. package/cjs/CheckPicker/CheckPicker.js +14 -15
  45. package/cjs/CheckTree/CheckTree.js +1 -1
  46. package/cjs/CheckTree/CheckTreeNode.js +3 -4
  47. package/cjs/CheckTree/CheckTreeView.js +5 -5
  48. package/cjs/CheckTree/hooks/useTreeCheckState.js +2 -2
  49. package/cjs/CheckTree/utils.js +9 -17
  50. package/cjs/CheckTreePicker/CheckTreePicker.js +7 -7
  51. package/cjs/CheckTreePicker/hooks/useFocusState.d.ts +0 -1
  52. package/cjs/CheckTreePicker/hooks/useFocusState.js +3 -6
  53. package/cjs/Checkbox/Checkbox.js +4 -5
  54. package/cjs/Checkbox/hooks/useIndeterminateCheckbox.d.ts +0 -1
  55. package/cjs/Checkbox/hooks/useIndeterminateCheckbox.js +1 -1
  56. package/cjs/CheckboxGroup/CheckboxGroup.js +2 -2
  57. package/cjs/DOMHelper/index.d.ts +1 -2
  58. package/cjs/DOMHelper/isElement.js +1 -1
  59. package/cjs/DateInput/DateField.d.ts +122 -3
  60. package/cjs/DateInput/DateField.js +12 -15
  61. package/cjs/DateInput/DateInput.js +3 -4
  62. package/cjs/DateInput/hooks/useDateInputState.d.ts +124 -4
  63. package/cjs/DateInput/hooks/useDateInputState.js +2 -2
  64. package/cjs/DateInput/hooks/useIsFocused.js +2 -2
  65. package/cjs/DateInput/hooks/useKeyboardInputEvent.d.ts +0 -1
  66. package/cjs/DateInput/hooks/useKeyboardInputEvent.js +8 -9
  67. package/cjs/DateInput/hooks/useSelectedState.d.ts +0 -1
  68. package/cjs/DateInput/utils.d.ts +0 -1
  69. package/cjs/DateInput/utils.js +2 -3
  70. package/cjs/DatePicker/DatePicker.js +18 -25
  71. package/cjs/DatePicker/PredefinedRanges.js +3 -3
  72. package/cjs/DatePicker/Toolbar.js +4 -4
  73. package/cjs/DatePicker/hooks/useCustomizedInput.d.ts +0 -1
  74. package/cjs/DatePicker/hooks/useFocus.js +5 -8
  75. package/cjs/DatePicker/hooks/useMonthView.d.ts +0 -1
  76. package/cjs/DatePicker/hooks/useMonthView.js +1 -1
  77. package/cjs/DatePicker/utils.d.ts +1 -2
  78. package/cjs/DatePicker/utils.js +2 -2
  79. package/cjs/DateRangeInput/DateRangeInput.js +8 -9
  80. package/cjs/DateRangePicker/Calendar.js +2 -2
  81. package/cjs/DateRangePicker/DateRangePicker.js +25 -29
  82. package/cjs/DateRangePicker/Header.js +3 -3
  83. package/cjs/DateRangePicker/disabledDateUtils.js +2 -2
  84. package/cjs/DateRangePicker/hooks/useCalendarHandlers.d.ts +0 -1
  85. package/cjs/DateRangePicker/hooks/useCalendarHandlers.js +5 -5
  86. package/cjs/DateRangePicker/utils.js +1 -2
  87. package/cjs/Dropdown/Dropdown.js +3 -3
  88. package/cjs/Dropdown/DropdownItem.js +4 -5
  89. package/cjs/Dropdown/DropdownMenu.d.ts +1 -1
  90. package/cjs/Dropdown/DropdownMenu.js +1 -1
  91. package/cjs/Form/Form.d.ts +38 -3
  92. package/cjs/Form/Form.js +25 -12
  93. package/cjs/Form/hooks/useFormRef.d.ts +0 -1
  94. package/cjs/Form/hooks/useFormValidate.d.ts +2 -1
  95. package/cjs/Form/hooks/useFormValidate.js +136 -20
  96. package/cjs/Form/hooks/useFormValue.d.ts +0 -1
  97. package/cjs/Form/index.d.ts +1 -0
  98. package/cjs/Form/resolvers.d.ts +59 -0
  99. package/cjs/Form/resolvers.js +4 -0
  100. package/cjs/FormControl/FormControl.js +5 -5
  101. package/cjs/FormGroup/FormGroupContext.d.ts +1 -1
  102. package/cjs/Highlight/utils/highlightText.js +1 -1
  103. package/cjs/InlineEdit/renderChildren.js +5 -6
  104. package/cjs/InlineEdit/useEditState.js +9 -12
  105. package/cjs/InlineEdit/useFocusEvent.d.ts +0 -1
  106. package/cjs/InlineEdit/useFocusEvent.js +7 -11
  107. package/cjs/Input/Input.js +1 -1
  108. package/cjs/InputGroup/InputGroupContext.d.ts +2 -1
  109. package/cjs/InputNumber/index.d.ts +0 -1
  110. package/cjs/InputPicker/InputAutosize.js +1 -1
  111. package/cjs/InputPicker/InputPicker.js +30 -35
  112. package/cjs/InputPicker/InputSearch.js +1 -2
  113. package/cjs/InputPicker/hooks/useData.d.ts +0 -1
  114. package/cjs/InputPicker/hooks/useData.js +1 -1
  115. package/cjs/InputPicker/hooks/useInput.js +3 -6
  116. package/cjs/InputPicker/hooks/useMaxWidth.js +2 -4
  117. package/cjs/List/helper/AutoScroller.js +2 -4
  118. package/cjs/List/helper/useSortHelper.d.ts +4 -4
  119. package/cjs/List/helper/useSortHelper.js +13 -19
  120. package/cjs/MaskedInput/TextMask.d.ts +5 -5
  121. package/cjs/MaskedInput/TextMask.js +3 -5
  122. package/cjs/MaskedInput/conformToMask.d.ts +1 -1
  123. package/cjs/MaskedInput/createTextMaskInputElement.js +2 -3
  124. package/cjs/Menu/MenuItem.js +3 -4
  125. package/cjs/Message/Message.js +1 -1
  126. package/cjs/Modal/Modal.js +8 -10
  127. package/cjs/Modal/ModalBody.js +1 -1
  128. package/cjs/Modal/utils.d.ts +2 -3
  129. package/cjs/Modal/utils.js +2 -3
  130. package/cjs/MultiCascadeTree/SearchView.js +1 -1
  131. package/cjs/MultiCascadeTree/TreeView.js +2 -2
  132. package/cjs/MultiCascadeTree/hooks/useCascadeValue.d.ts +0 -1
  133. package/cjs/MultiCascadeTree/hooks/useCascadeValue.js +5 -8
  134. package/cjs/MultiCascadeTree/hooks/useColumnData.d.ts +0 -1
  135. package/cjs/MultiCascadeTree/hooks/useSearch.d.ts +0 -1
  136. package/cjs/MultiCascadeTree/hooks/useSearch.js +2 -2
  137. package/cjs/MultiCascadeTree/hooks/useSelect.js +3 -4
  138. package/cjs/MultiCascadeTree/types.d.ts +0 -1
  139. package/cjs/MultiCascadeTree/utils.d.ts +4 -4
  140. package/cjs/MultiCascadeTree/utils.js +2 -3
  141. package/cjs/MultiCascader/MultiCascader.js +13 -16
  142. package/cjs/Nav/AdaptiveNavItem.js +2 -3
  143. package/cjs/Nav/Nav.d.ts +1 -1
  144. package/cjs/Nav/Nav.js +4 -4
  145. package/cjs/Nav/NavDropdown.d.ts +1 -1
  146. package/cjs/Nav/NavDropdown.js +3 -3
  147. package/cjs/Nav/NavDropdownItem.js +2 -2
  148. package/cjs/Nav/NavDropdownMenu.d.ts +1 -1
  149. package/cjs/Nav/NavDropdownMenu.js +1 -1
  150. package/cjs/Nav/NavItem.js +4 -4
  151. package/cjs/Navbar/Navbar.js +1 -1
  152. package/cjs/Navbar/NavbarContent.js +1 -1
  153. package/cjs/Navbar/NavbarDrawer.js +1 -1
  154. package/cjs/Navbar/NavbarDropdown.d.ts +1 -1
  155. package/cjs/Navbar/NavbarDropdown.js +3 -3
  156. package/cjs/Navbar/NavbarDropdownItem.js +5 -6
  157. package/cjs/Navbar/NavbarDropdownMenu.d.ts +1 -1
  158. package/cjs/Navbar/NavbarDropdownMenu.js +1 -1
  159. package/cjs/Navbar/NavbarItem.js +4 -4
  160. package/cjs/Navbar/NavbarToggle.js +2 -2
  161. package/cjs/Notification/Notification.js +1 -1
  162. package/cjs/NumberInput/NumberInput.js +3 -3
  163. package/cjs/NumberInput/hooks/useEvents.d.ts +0 -1
  164. package/cjs/NumberInput/hooks/useEvents.js +2 -3
  165. package/cjs/NumberInput/hooks/useWheelHandler.js +1 -2
  166. package/cjs/Pagination/Pagination.js +1 -1
  167. package/cjs/Pagination/PaginationButton.js +1 -1
  168. package/cjs/Pagination/PaginationGroup.js +3 -4
  169. package/cjs/Panel/Panel.js +2 -2
  170. package/cjs/PanelGroup/PanelGroup.js +1 -1
  171. package/cjs/PasswordInput/PasswordInput.js +2 -2
  172. package/cjs/PinInput/PinInput.js +1 -1
  173. package/cjs/PinInput/hooks/usePinInputRefs.d.ts +0 -1
  174. package/cjs/PinInput/hooks/usePinInputRefs.js +2 -4
  175. package/cjs/PinInput/hooks/usePinValue.d.ts +1 -1
  176. package/cjs/PinInput/hooks/usePinValue.js +2 -2
  177. package/cjs/Progress/ProgressLine.js +1 -1
  178. package/cjs/Progress/types.d.ts +0 -1
  179. package/cjs/ProgressCircle/hooks/useProgressCirclePath.d.ts +0 -1
  180. package/cjs/Radio/Radio.js +3 -3
  181. package/cjs/RadioGroup/RadioGroup.js +1 -1
  182. package/cjs/RadioTile/RadioTile.js +2 -2
  183. package/cjs/RadioTileGroup/RadioTileGroup.js +1 -1
  184. package/cjs/RangeSlider/RangeSlider.js +6 -6
  185. package/cjs/Rate/Character.js +2 -2
  186. package/cjs/Rate/Rate.js +3 -3
  187. package/cjs/Rate/useRatingStates.d.ts +0 -1
  188. package/cjs/SegmentedControl/SegmentedControl.js +3 -3
  189. package/cjs/SegmentedControl/hooks/useIndicatorPosition.js +1 -1
  190. package/cjs/SelectPicker/SelectPicker.js +13 -16
  191. package/cjs/Sidebar/Sidebar.js +1 -1
  192. package/cjs/Sidenav/ExpandedSidenavDropdown.js +6 -6
  193. package/cjs/Sidenav/ExpandedSidenavDropdownItem.js +4 -5
  194. package/cjs/Sidenav/Node.js +9 -16
  195. package/cjs/Sidenav/Sidenav.js +2 -2
  196. package/cjs/Sidenav/SidenavDropdown.d.ts +1 -1
  197. package/cjs/Sidenav/SidenavDropdown.js +4 -4
  198. package/cjs/Sidenav/SidenavDropdownItem.js +3 -4
  199. package/cjs/Sidenav/SidenavItem.js +5 -6
  200. package/cjs/Sidenav/SidenavToggle.js +2 -2
  201. package/cjs/Slider/Slider.js +3 -3
  202. package/cjs/Slider/useDrag.d.ts +0 -1
  203. package/cjs/Slider/useDrag.js +7 -12
  204. package/cjs/Slider/utils.d.ts +1 -2
  205. package/cjs/Slider/utils.js +2 -3
  206. package/cjs/Steps/StepItem.js +1 -2
  207. package/cjs/Table/Table.d.ts +3 -3
  208. package/cjs/Tabs/Tabs.js +3 -4
  209. package/cjs/TimePicker/TimePicker.js +2 -2
  210. package/cjs/Timeline/Timeline.d.ts +6 -1
  211. package/cjs/Timeline/Timeline.js +14 -10
  212. package/cjs/Toggle/Toggle.js +2 -2
  213. package/cjs/Tree/Tree.js +2 -2
  214. package/cjs/Tree/TreeNode.js +10 -11
  215. package/cjs/Tree/TreeView.js +5 -5
  216. package/cjs/Tree/hooks/useExpandTree.js +1 -1
  217. package/cjs/Tree/hooks/useFlattenTree.js +6 -9
  218. package/cjs/Tree/hooks/useFocusTree.d.ts +1 -2
  219. package/cjs/Tree/hooks/useFocusTree.js +12 -14
  220. package/cjs/Tree/hooks/useTreeDrag.d.ts +0 -1
  221. package/cjs/Tree/hooks/useTreeDrag.js +10 -12
  222. package/cjs/Tree/hooks/useTreeNodeProps.js +1 -1
  223. package/cjs/Tree/hooks/useTreeSearch.js +4 -4
  224. package/cjs/Tree/hooks/useVirtualizedTreeData.js +2 -2
  225. package/cjs/Tree/types.d.ts +2 -3
  226. package/cjs/Tree/utils/flattenTree.d.ts +1 -1
  227. package/cjs/Tree/utils/focusableTree.js +5 -8
  228. package/cjs/Tree/utils/getNodeParentKeys.js +2 -4
  229. package/cjs/Tree/utils/hasVisibleChildren.d.ts +1 -1
  230. package/cjs/Tree/utils/treeKeyboardInteractions.js +3 -3
  231. package/cjs/TreePicker/TreePicker.js +8 -9
  232. package/cjs/TreePicker/hooks/useFocusState.d.ts +0 -1
  233. package/cjs/TreePicker/hooks/useFocusState.js +4 -8
  234. package/cjs/Uploader/UploadFileItem.js +8 -10
  235. package/cjs/Uploader/UploadTrigger.js +8 -10
  236. package/cjs/Uploader/Uploader.d.ts +2 -0
  237. package/cjs/Uploader/Uploader.js +66 -26
  238. package/cjs/Uploader/utils/ajaxUpload.js +5 -5
  239. package/cjs/Uploader/utils/previewFile.js +1 -1
  240. package/cjs/internals/Disclosure/Disclosure.js +5 -8
  241. package/cjs/internals/Disclosure/DisclosureButton.js +2 -2
  242. package/cjs/internals/InputBase/InputBase.js +5 -6
  243. package/cjs/internals/Menu/Menu.js +16 -20
  244. package/cjs/internals/Menu/MenuItem.js +4 -5
  245. package/cjs/internals/Menu/Menubar.js +5 -7
  246. package/cjs/internals/Menu/useMenu.js +5 -10
  247. package/cjs/internals/Overlay/Modal.js +8 -11
  248. package/cjs/internals/Overlay/ModalManager.js +3 -5
  249. package/cjs/internals/Overlay/Overlay.js +1 -1
  250. package/cjs/internals/Overlay/OverlayTrigger.d.ts +0 -1
  251. package/cjs/internals/Overlay/OverlayTrigger.js +5 -7
  252. package/cjs/internals/Overlay/Position.js +6 -8
  253. package/cjs/internals/Picker/ListCheckItem.js +3 -3
  254. package/cjs/internals/Picker/ListItem.js +1 -1
  255. package/cjs/internals/Picker/Listbox.js +9 -10
  256. package/cjs/internals/Picker/PickerIndicator.js +13 -11
  257. package/cjs/internals/Picker/PickerPopup.js +4 -5
  258. package/cjs/internals/Picker/PickerToggle.js +3 -4
  259. package/cjs/internals/Picker/SelectedElement.js +1 -1
  260. package/cjs/internals/Picker/hooks/useFocusItemValue.d.ts +0 -1
  261. package/cjs/internals/Picker/hooks/useFocusItemValue.js +14 -28
  262. package/cjs/internals/Picker/hooks/usePickerRef.d.ts +0 -1
  263. package/cjs/internals/Picker/hooks/usePickerRef.js +9 -15
  264. package/cjs/internals/Picker/hooks/useSearch.d.ts +0 -1
  265. package/cjs/internals/Picker/hooks/useSearch.js +2 -2
  266. package/cjs/internals/Picker/hooks/useToggleKeyDownEvent.d.ts +0 -1
  267. package/cjs/internals/Picker/hooks/useToggleKeyDownEvent.js +13 -17
  268. package/cjs/internals/Picker/utils.js +9 -9
  269. package/cjs/internals/Ripple/Ripple.js +3 -4
  270. package/cjs/internals/SafeAnchor/SafeAnchor.js +1 -1
  271. package/cjs/internals/ScrollView/hooks/useScrollState.d.ts +0 -1
  272. package/cjs/internals/ScrollView/hooks/useScrollState.js +2 -3
  273. package/cjs/internals/Tree/TreeProvider.d.ts +4 -4
  274. package/cjs/internals/Tree/TreeProvider.js +2 -8
  275. package/cjs/internals/Tree/types.d.ts +0 -1
  276. package/cjs/internals/Tree/utils/getParentMap.d.ts +0 -1
  277. package/cjs/internals/Windowing/AutoSizer.js +2 -3
  278. package/cjs/internals/Windowing/List.js +4 -8
  279. package/cjs/internals/constants/index.d.ts +2 -2
  280. package/cjs/internals/hooks/useClickOutside.js +2 -4
  281. package/cjs/internals/hooks/useCustom.d.ts +0 -1
  282. package/cjs/internals/hooks/useCustom.js +5 -7
  283. package/cjs/internals/hooks/useElementResize.d.ts +0 -1
  284. package/cjs/internals/hooks/useEventCallback.js +1 -2
  285. package/cjs/internals/hooks/useEventListener.js +1 -1
  286. package/cjs/internals/hooks/useFocus.js +2 -4
  287. package/cjs/internals/hooks/useFocusVirtualListItem.d.ts +0 -1
  288. package/cjs/internals/hooks/useMount.js +1 -2
  289. package/cjs/internals/hooks/useRootClose.js +6 -6
  290. package/cjs/internals/hooks/useTimeout.js +1 -2
  291. package/cjs/internals/hooks/useToggleCaret.d.ts +0 -1
  292. package/cjs/internals/hooks/useUniqueId.js +1 -1
  293. package/cjs/internals/hooks/useUpdatedRef.d.ts +0 -1
  294. package/cjs/internals/styled-system/style-manager.js +1 -1
  295. package/cjs/internals/styled-system/useStyled.js +2 -2
  296. package/cjs/internals/types/utils.d.ts +0 -1
  297. package/cjs/internals/utils/colours.d.ts +4 -4
  298. package/cjs/internals/utils/colours.js +1 -1
  299. package/cjs/internals/utils/date/disableTime.js +6 -12
  300. package/cjs/internals/utils/date/omitHideDisabledProps.d.ts +1 -1
  301. package/cjs/internals/utils/date/useDateMode.d.ts +1 -1
  302. package/cjs/internals/utils/react/ReactChildren.js +1 -2
  303. package/cjs/internals/utils/react/deprecateComponent.js +1 -2
  304. package/cjs/internals/utils/react/getDOMNode.js +4 -5
  305. package/cjs/internals/utils/sizes.d.ts +2 -2
  306. package/cjs/internals/utils/style-sheet/css.d.ts +0 -1
  307. package/cjs/internals/utils/style-sheet/css.js +1 -1
  308. package/cjs/internals/utils/style-sheet/prefix.d.ts +0 -1
  309. package/cjs/internals/utils/style-sheet/responsive.d.ts +1 -1
  310. package/cjs/internals/utils/style-sheet/styles.d.ts +3 -3
  311. package/cjs/internals/utils/style-sheet/styles.js +1 -1
  312. package/cjs/toaster/ToastContainer.js +3 -5
  313. package/cjs/toaster/hooks/useDelayedClosure.d.ts +0 -1
  314. package/cjs/toaster/hooks/useDelayedClosure.js +3 -4
  315. package/cjs/toaster/toaster.js +42 -15
  316. package/cjs/useDialog/Dialog.d.ts +1 -1
  317. package/cjs/useDialog/Dialog.js +1 -1
  318. package/cjs/useDialog/useDialog.d.ts +1 -1
  319. package/cjs/useDialog/useDialog.js +3 -3
  320. package/cjs/useFormControl/hooks/useField.d.ts +0 -1
  321. package/cjs/useFormControl/hooks/useField.js +5 -7
  322. package/cjs/useFormControl/hooks/useRegisterModel.js +2 -2
  323. package/cjs/useFormControl/useFormControl.js +8 -8
  324. package/cjs/useToaster/useToaster.js +4 -5
  325. package/dist/rsuite-no-reset.css +14 -0
  326. package/dist/rsuite-no-reset.min.css +1 -1
  327. package/dist/rsuite.css +14 -0
  328. package/dist/rsuite.js +224 -224
  329. package/dist/rsuite.min.css +1 -1
  330. package/dist/rsuite.min.js +1 -1
  331. package/dist/rsuite.min.js.map +1 -1
  332. package/esm/Affix/Affix.js +4 -4
  333. package/esm/Animation/Collapse.js +1 -2
  334. package/esm/Animation/Transition.d.ts +2 -2
  335. package/esm/Animation/Transition.js +17 -20
  336. package/esm/AutoComplete/AutoComplete.d.ts +2 -0
  337. package/esm/AutoComplete/AutoComplete.js +12 -10
  338. package/esm/Avatar/useImage.js +1 -1
  339. package/esm/AvatarGroup/AvatarGroup.d.ts +2 -2
  340. package/esm/Badge/Badge.js +1 -4
  341. package/esm/Breadcrumb/Breadcrumb.js +4 -4
  342. package/esm/Button/Button.js +6 -6
  343. package/esm/Calendar/Calendar.js +5 -5
  344. package/esm/Calendar/CalendarBody.js +1 -1
  345. package/esm/Calendar/CalendarContainer.js +14 -33
  346. package/esm/Calendar/CalendarHeader.js +7 -8
  347. package/esm/Calendar/Grid/GridCell.js +2 -2
  348. package/esm/Calendar/Grid/GridHeaderRow.js +1 -1
  349. package/esm/Calendar/Grid/GridRow.js +5 -6
  350. package/esm/Calendar/MonthDropdown/MonthDropdown.js +1 -1
  351. package/esm/Calendar/MonthDropdown/MonthDropdownItem.js +1 -1
  352. package/esm/Calendar/TimeDropdown/TimeDropdown.js +12 -14
  353. package/esm/Calendar/hooks/useCalendar.d.ts +16 -17
  354. package/esm/Calendar/hooks/useCalendar.js +2 -4
  355. package/esm/Calendar/hooks/useCalendarDate.js +5 -9
  356. package/esm/Calendar/hooks/useCalendarState.js +6 -12
  357. package/esm/Calendar/types.d.ts +0 -1
  358. package/esm/Carousel/Carousel.js +5 -6
  359. package/esm/CascadeTree/CascadeTree.js +6 -16
  360. package/esm/CascadeTree/TreeView.js +5 -7
  361. package/esm/CascadeTree/hooks/useSearch.d.ts +0 -1
  362. package/esm/CascadeTree/hooks/useSearch.js +1 -1
  363. package/esm/CascadeTree/hooks/useSelect.d.ts +0 -1
  364. package/esm/CascadeTree/hooks/useSelect.js +3 -4
  365. package/esm/CascadeTree/types.d.ts +0 -1
  366. package/esm/CascadeTree/utils.js +1 -2
  367. package/esm/Cascader/Cascader.js +18 -29
  368. package/esm/Cascader/useActive.d.ts +0 -1
  369. package/esm/Cascader/useActive.js +4 -6
  370. package/esm/CheckPicker/CheckPicker.js +14 -15
  371. package/esm/CheckTree/CheckTree.js +1 -1
  372. package/esm/CheckTree/CheckTreeNode.js +3 -4
  373. package/esm/CheckTree/CheckTreeView.js +5 -5
  374. package/esm/CheckTree/hooks/useTreeCheckState.js +2 -2
  375. package/esm/CheckTree/utils.js +9 -17
  376. package/esm/CheckTreePicker/CheckTreePicker.js +7 -7
  377. package/esm/CheckTreePicker/hooks/useFocusState.d.ts +0 -1
  378. package/esm/CheckTreePicker/hooks/useFocusState.js +3 -6
  379. package/esm/Checkbox/Checkbox.js +4 -5
  380. package/esm/Checkbox/hooks/useIndeterminateCheckbox.d.ts +0 -1
  381. package/esm/Checkbox/hooks/useIndeterminateCheckbox.js +1 -1
  382. package/esm/CheckboxGroup/CheckboxGroup.js +2 -2
  383. package/esm/DOMHelper/index.d.ts +1 -2
  384. package/esm/DOMHelper/isElement.js +1 -1
  385. package/esm/DateInput/DateField.d.ts +122 -3
  386. package/esm/DateInput/DateField.js +12 -15
  387. package/esm/DateInput/DateInput.js +3 -4
  388. package/esm/DateInput/hooks/useDateInputState.d.ts +124 -4
  389. package/esm/DateInput/hooks/useDateInputState.js +2 -2
  390. package/esm/DateInput/hooks/useIsFocused.js +2 -2
  391. package/esm/DateInput/hooks/useKeyboardInputEvent.d.ts +0 -1
  392. package/esm/DateInput/hooks/useKeyboardInputEvent.js +8 -9
  393. package/esm/DateInput/hooks/useSelectedState.d.ts +0 -1
  394. package/esm/DateInput/utils.d.ts +0 -1
  395. package/esm/DateInput/utils.js +2 -3
  396. package/esm/DatePicker/DatePicker.js +18 -25
  397. package/esm/DatePicker/PredefinedRanges.js +3 -3
  398. package/esm/DatePicker/Toolbar.js +4 -4
  399. package/esm/DatePicker/hooks/useCustomizedInput.d.ts +0 -1
  400. package/esm/DatePicker/hooks/useFocus.js +5 -8
  401. package/esm/DatePicker/hooks/useMonthView.d.ts +0 -1
  402. package/esm/DatePicker/hooks/useMonthView.js +1 -1
  403. package/esm/DatePicker/utils.d.ts +1 -2
  404. package/esm/DatePicker/utils.js +2 -2
  405. package/esm/DateRangeInput/DateRangeInput.js +8 -9
  406. package/esm/DateRangePicker/Calendar.js +2 -2
  407. package/esm/DateRangePicker/DateRangePicker.js +25 -29
  408. package/esm/DateRangePicker/Header.js +3 -3
  409. package/esm/DateRangePicker/disabledDateUtils.js +2 -2
  410. package/esm/DateRangePicker/hooks/useCalendarHandlers.d.ts +0 -1
  411. package/esm/DateRangePicker/hooks/useCalendarHandlers.js +5 -5
  412. package/esm/DateRangePicker/utils.js +1 -2
  413. package/esm/Dropdown/Dropdown.js +3 -3
  414. package/esm/Dropdown/DropdownItem.js +4 -5
  415. package/esm/Dropdown/DropdownMenu.d.ts +1 -1
  416. package/esm/Dropdown/DropdownMenu.js +1 -1
  417. package/esm/Form/Form.d.ts +38 -3
  418. package/esm/Form/Form.js +25 -12
  419. package/esm/Form/hooks/useFormRef.d.ts +0 -1
  420. package/esm/Form/hooks/useFormValidate.d.ts +2 -1
  421. package/esm/Form/hooks/useFormValidate.js +136 -20
  422. package/esm/Form/hooks/useFormValue.d.ts +0 -1
  423. package/esm/Form/index.d.ts +1 -0
  424. package/esm/Form/resolvers.d.ts +59 -0
  425. package/esm/Form/resolvers.js +2 -0
  426. package/esm/FormControl/FormControl.js +5 -5
  427. package/esm/FormGroup/FormGroupContext.d.ts +1 -1
  428. package/esm/Highlight/utils/highlightText.js +1 -1
  429. package/esm/InlineEdit/renderChildren.js +5 -6
  430. package/esm/InlineEdit/useEditState.js +9 -12
  431. package/esm/InlineEdit/useFocusEvent.d.ts +0 -1
  432. package/esm/InlineEdit/useFocusEvent.js +7 -11
  433. package/esm/Input/Input.js +1 -1
  434. package/esm/InputGroup/InputGroupContext.d.ts +2 -1
  435. package/esm/InputNumber/index.d.ts +0 -1
  436. package/esm/InputPicker/InputAutosize.js +1 -1
  437. package/esm/InputPicker/InputPicker.js +30 -35
  438. package/esm/InputPicker/InputSearch.js +1 -2
  439. package/esm/InputPicker/hooks/useData.d.ts +0 -1
  440. package/esm/InputPicker/hooks/useData.js +1 -1
  441. package/esm/InputPicker/hooks/useInput.js +3 -6
  442. package/esm/InputPicker/hooks/useMaxWidth.js +2 -4
  443. package/esm/List/helper/AutoScroller.js +2 -4
  444. package/esm/List/helper/useSortHelper.d.ts +4 -4
  445. package/esm/List/helper/useSortHelper.js +13 -19
  446. package/esm/MaskedInput/TextMask.d.ts +5 -5
  447. package/esm/MaskedInput/TextMask.js +3 -5
  448. package/esm/MaskedInput/conformToMask.d.ts +1 -1
  449. package/esm/MaskedInput/createTextMaskInputElement.js +2 -3
  450. package/esm/Menu/MenuItem.js +3 -4
  451. package/esm/Message/Message.js +1 -1
  452. package/esm/Modal/Modal.js +8 -10
  453. package/esm/Modal/ModalBody.js +1 -1
  454. package/esm/Modal/utils.d.ts +2 -3
  455. package/esm/Modal/utils.js +2 -3
  456. package/esm/MultiCascadeTree/SearchView.js +1 -1
  457. package/esm/MultiCascadeTree/TreeView.js +2 -2
  458. package/esm/MultiCascadeTree/hooks/useCascadeValue.d.ts +0 -1
  459. package/esm/MultiCascadeTree/hooks/useCascadeValue.js +5 -8
  460. package/esm/MultiCascadeTree/hooks/useColumnData.d.ts +0 -1
  461. package/esm/MultiCascadeTree/hooks/useSearch.d.ts +0 -1
  462. package/esm/MultiCascadeTree/hooks/useSearch.js +2 -2
  463. package/esm/MultiCascadeTree/hooks/useSelect.js +3 -4
  464. package/esm/MultiCascadeTree/types.d.ts +0 -1
  465. package/esm/MultiCascadeTree/utils.d.ts +4 -4
  466. package/esm/MultiCascadeTree/utils.js +2 -3
  467. package/esm/MultiCascader/MultiCascader.js +13 -16
  468. package/esm/Nav/AdaptiveNavItem.js +2 -3
  469. package/esm/Nav/Nav.d.ts +1 -1
  470. package/esm/Nav/Nav.js +4 -4
  471. package/esm/Nav/NavDropdown.d.ts +1 -1
  472. package/esm/Nav/NavDropdown.js +3 -3
  473. package/esm/Nav/NavDropdownItem.js +2 -2
  474. package/esm/Nav/NavDropdownMenu.d.ts +1 -1
  475. package/esm/Nav/NavDropdownMenu.js +1 -1
  476. package/esm/Nav/NavItem.js +4 -4
  477. package/esm/Navbar/Navbar.js +1 -1
  478. package/esm/Navbar/NavbarContent.js +1 -1
  479. package/esm/Navbar/NavbarDrawer.js +1 -1
  480. package/esm/Navbar/NavbarDropdown.d.ts +1 -1
  481. package/esm/Navbar/NavbarDropdown.js +3 -3
  482. package/esm/Navbar/NavbarDropdownItem.js +5 -6
  483. package/esm/Navbar/NavbarDropdownMenu.d.ts +1 -1
  484. package/esm/Navbar/NavbarDropdownMenu.js +1 -1
  485. package/esm/Navbar/NavbarItem.js +4 -4
  486. package/esm/Navbar/NavbarToggle.js +2 -2
  487. package/esm/Notification/Notification.js +1 -1
  488. package/esm/NumberInput/NumberInput.js +3 -3
  489. package/esm/NumberInput/hooks/useEvents.d.ts +0 -1
  490. package/esm/NumberInput/hooks/useEvents.js +2 -3
  491. package/esm/NumberInput/hooks/useWheelHandler.js +1 -2
  492. package/esm/Pagination/Pagination.js +1 -1
  493. package/esm/Pagination/PaginationButton.js +1 -1
  494. package/esm/Pagination/PaginationGroup.js +3 -4
  495. package/esm/Panel/Panel.js +2 -2
  496. package/esm/PanelGroup/PanelGroup.js +1 -1
  497. package/esm/PasswordInput/PasswordInput.js +2 -2
  498. package/esm/PinInput/PinInput.js +1 -1
  499. package/esm/PinInput/hooks/usePinInputRefs.d.ts +0 -1
  500. package/esm/PinInput/hooks/usePinInputRefs.js +2 -4
  501. package/esm/PinInput/hooks/usePinValue.d.ts +1 -1
  502. package/esm/PinInput/hooks/usePinValue.js +2 -2
  503. package/esm/Progress/ProgressLine.js +1 -1
  504. package/esm/Progress/types.d.ts +0 -1
  505. package/esm/ProgressCircle/hooks/useProgressCirclePath.d.ts +0 -1
  506. package/esm/Radio/Radio.js +3 -3
  507. package/esm/RadioGroup/RadioGroup.js +1 -1
  508. package/esm/RadioTile/RadioTile.js +2 -2
  509. package/esm/RadioTileGroup/RadioTileGroup.js +1 -1
  510. package/esm/RangeSlider/RangeSlider.js +6 -6
  511. package/esm/Rate/Character.js +2 -2
  512. package/esm/Rate/Rate.js +3 -3
  513. package/esm/Rate/useRatingStates.d.ts +0 -1
  514. package/esm/SegmentedControl/SegmentedControl.js +3 -3
  515. package/esm/SegmentedControl/hooks/useIndicatorPosition.js +1 -1
  516. package/esm/SelectPicker/SelectPicker.js +13 -16
  517. package/esm/Sidebar/Sidebar.js +1 -1
  518. package/esm/Sidenav/ExpandedSidenavDropdown.js +6 -6
  519. package/esm/Sidenav/ExpandedSidenavDropdownItem.js +4 -5
  520. package/esm/Sidenav/Node.js +9 -16
  521. package/esm/Sidenav/Sidenav.js +2 -2
  522. package/esm/Sidenav/SidenavDropdown.d.ts +1 -1
  523. package/esm/Sidenav/SidenavDropdown.js +4 -4
  524. package/esm/Sidenav/SidenavDropdownItem.js +3 -4
  525. package/esm/Sidenav/SidenavItem.js +5 -6
  526. package/esm/Sidenav/SidenavToggle.js +2 -2
  527. package/esm/Slider/Slider.js +3 -3
  528. package/esm/Slider/useDrag.d.ts +0 -1
  529. package/esm/Slider/useDrag.js +7 -12
  530. package/esm/Slider/utils.d.ts +1 -2
  531. package/esm/Slider/utils.js +2 -3
  532. package/esm/Steps/StepItem.js +1 -2
  533. package/esm/Table/Table.d.ts +3 -3
  534. package/esm/Tabs/Tabs.js +3 -4
  535. package/esm/TimePicker/TimePicker.js +2 -2
  536. package/esm/Timeline/Timeline.d.ts +6 -1
  537. package/esm/Timeline/Timeline.js +14 -10
  538. package/esm/Toggle/Toggle.js +2 -2
  539. package/esm/Tree/Tree.js +2 -2
  540. package/esm/Tree/TreeNode.js +10 -11
  541. package/esm/Tree/TreeView.js +5 -5
  542. package/esm/Tree/hooks/useExpandTree.js +1 -1
  543. package/esm/Tree/hooks/useFlattenTree.js +6 -9
  544. package/esm/Tree/hooks/useFocusTree.d.ts +1 -2
  545. package/esm/Tree/hooks/useFocusTree.js +12 -14
  546. package/esm/Tree/hooks/useTreeDrag.d.ts +0 -1
  547. package/esm/Tree/hooks/useTreeDrag.js +10 -12
  548. package/esm/Tree/hooks/useTreeNodeProps.js +1 -1
  549. package/esm/Tree/hooks/useTreeSearch.js +4 -4
  550. package/esm/Tree/hooks/useVirtualizedTreeData.js +2 -2
  551. package/esm/Tree/types.d.ts +2 -3
  552. package/esm/Tree/utils/flattenTree.d.ts +1 -1
  553. package/esm/Tree/utils/focusableTree.js +5 -8
  554. package/esm/Tree/utils/getNodeParentKeys.js +2 -4
  555. package/esm/Tree/utils/hasVisibleChildren.d.ts +1 -1
  556. package/esm/Tree/utils/treeKeyboardInteractions.js +3 -3
  557. package/esm/TreePicker/TreePicker.js +8 -9
  558. package/esm/TreePicker/hooks/useFocusState.d.ts +0 -1
  559. package/esm/TreePicker/hooks/useFocusState.js +4 -8
  560. package/esm/Uploader/UploadFileItem.js +8 -10
  561. package/esm/Uploader/UploadTrigger.js +8 -10
  562. package/esm/Uploader/Uploader.d.ts +2 -0
  563. package/esm/Uploader/Uploader.js +66 -26
  564. package/esm/Uploader/utils/ajaxUpload.js +5 -5
  565. package/esm/Uploader/utils/previewFile.js +1 -1
  566. package/esm/internals/Disclosure/Disclosure.js +5 -8
  567. package/esm/internals/Disclosure/DisclosureButton.js +2 -2
  568. package/esm/internals/InputBase/InputBase.js +5 -6
  569. package/esm/internals/Menu/Menu.js +16 -20
  570. package/esm/internals/Menu/MenuItem.js +4 -5
  571. package/esm/internals/Menu/Menubar.js +5 -7
  572. package/esm/internals/Menu/useMenu.js +5 -10
  573. package/esm/internals/Overlay/Modal.js +8 -11
  574. package/esm/internals/Overlay/ModalManager.js +3 -5
  575. package/esm/internals/Overlay/Overlay.js +1 -1
  576. package/esm/internals/Overlay/OverlayTrigger.d.ts +0 -1
  577. package/esm/internals/Overlay/OverlayTrigger.js +5 -7
  578. package/esm/internals/Overlay/Position.js +6 -8
  579. package/esm/internals/Picker/ListCheckItem.js +3 -3
  580. package/esm/internals/Picker/ListItem.js +1 -1
  581. package/esm/internals/Picker/Listbox.js +9 -10
  582. package/esm/internals/Picker/PickerIndicator.js +13 -11
  583. package/esm/internals/Picker/PickerPopup.js +4 -5
  584. package/esm/internals/Picker/PickerToggle.js +3 -4
  585. package/esm/internals/Picker/SelectedElement.js +1 -1
  586. package/esm/internals/Picker/hooks/useFocusItemValue.d.ts +0 -1
  587. package/esm/internals/Picker/hooks/useFocusItemValue.js +14 -28
  588. package/esm/internals/Picker/hooks/usePickerRef.d.ts +0 -1
  589. package/esm/internals/Picker/hooks/usePickerRef.js +9 -15
  590. package/esm/internals/Picker/hooks/useSearch.d.ts +0 -1
  591. package/esm/internals/Picker/hooks/useSearch.js +2 -2
  592. package/esm/internals/Picker/hooks/useToggleKeyDownEvent.d.ts +0 -1
  593. package/esm/internals/Picker/hooks/useToggleKeyDownEvent.js +13 -17
  594. package/esm/internals/Picker/utils.js +9 -9
  595. package/esm/internals/Ripple/Ripple.js +3 -4
  596. package/esm/internals/SafeAnchor/SafeAnchor.js +1 -1
  597. package/esm/internals/ScrollView/hooks/useScrollState.d.ts +0 -1
  598. package/esm/internals/ScrollView/hooks/useScrollState.js +2 -3
  599. package/esm/internals/Tree/TreeProvider.d.ts +4 -4
  600. package/esm/internals/Tree/TreeProvider.js +2 -8
  601. package/esm/internals/Tree/types.d.ts +0 -1
  602. package/esm/internals/Tree/utils/getParentMap.d.ts +0 -1
  603. package/esm/internals/Windowing/AutoSizer.js +2 -3
  604. package/esm/internals/Windowing/List.js +4 -8
  605. package/esm/internals/constants/index.d.ts +2 -2
  606. package/esm/internals/hooks/useClickOutside.js +2 -4
  607. package/esm/internals/hooks/useCustom.d.ts +0 -1
  608. package/esm/internals/hooks/useCustom.js +5 -7
  609. package/esm/internals/hooks/useElementResize.d.ts +0 -1
  610. package/esm/internals/hooks/useEventCallback.js +1 -2
  611. package/esm/internals/hooks/useEventListener.js +1 -1
  612. package/esm/internals/hooks/useFocus.js +2 -4
  613. package/esm/internals/hooks/useFocusVirtualListItem.d.ts +0 -1
  614. package/esm/internals/hooks/useMount.js +1 -2
  615. package/esm/internals/hooks/useRootClose.js +6 -6
  616. package/esm/internals/hooks/useTimeout.js +1 -2
  617. package/esm/internals/hooks/useToggleCaret.d.ts +0 -1
  618. package/esm/internals/hooks/useUniqueId.js +1 -1
  619. package/esm/internals/hooks/useUpdatedRef.d.ts +0 -1
  620. package/esm/internals/styled-system/style-manager.js +1 -1
  621. package/esm/internals/styled-system/useStyled.js +2 -2
  622. package/esm/internals/types/utils.d.ts +0 -1
  623. package/esm/internals/utils/colours.d.ts +4 -4
  624. package/esm/internals/utils/colours.js +1 -1
  625. package/esm/internals/utils/date/disableTime.js +6 -12
  626. package/esm/internals/utils/date/omitHideDisabledProps.d.ts +1 -1
  627. package/esm/internals/utils/date/useDateMode.d.ts +1 -1
  628. package/esm/internals/utils/react/ReactChildren.js +1 -2
  629. package/esm/internals/utils/react/deprecateComponent.js +1 -2
  630. package/esm/internals/utils/react/getDOMNode.js +4 -5
  631. package/esm/internals/utils/sizes.d.ts +2 -2
  632. package/esm/internals/utils/style-sheet/css.d.ts +0 -1
  633. package/esm/internals/utils/style-sheet/css.js +1 -1
  634. package/esm/internals/utils/style-sheet/prefix.d.ts +0 -1
  635. package/esm/internals/utils/style-sheet/responsive.d.ts +1 -1
  636. package/esm/internals/utils/style-sheet/styles.d.ts +3 -3
  637. package/esm/internals/utils/style-sheet/styles.js +1 -1
  638. package/esm/toaster/ToastContainer.js +3 -5
  639. package/esm/toaster/hooks/useDelayedClosure.d.ts +0 -1
  640. package/esm/toaster/hooks/useDelayedClosure.js +3 -4
  641. package/esm/toaster/toaster.js +42 -15
  642. package/esm/useDialog/Dialog.d.ts +1 -1
  643. package/esm/useDialog/Dialog.js +1 -1
  644. package/esm/useDialog/useDialog.d.ts +1 -1
  645. package/esm/useDialog/useDialog.js +3 -3
  646. package/esm/useFormControl/hooks/useField.d.ts +0 -1
  647. package/esm/useFormControl/hooks/useField.js +5 -7
  648. package/esm/useFormControl/hooks/useRegisterModel.js +2 -2
  649. package/esm/useFormControl/useFormControl.js +8 -8
  650. package/esm/useToaster/useToaster.js +4 -5
  651. package/package.json +1 -1
@@ -10,7 +10,8 @@ export default function useFormValidate(_formError, props) {
10
10
  getCombinedModel,
11
11
  onCheck,
12
12
  onError,
13
- nestedField
13
+ nestedField,
14
+ resolver
14
15
  } = props;
15
16
  const [realFormError, setFormError] = useControlled(_formError, {});
16
17
  const checkOptions = {
@@ -19,12 +20,64 @@ export default function useFormValidate(_formError, props) {
19
20
  const realFormErrorRef = useRef(realFormError);
20
21
  realFormErrorRef.current = realFormError;
21
22
 
23
+ /**
24
+ * Returns true when an error value is considered non-empty (i.e. the field has an error).
25
+ */
26
+ const isValidError = error => error !== undefined && error !== null && error !== '';
27
+
28
+ /**
29
+ * Merges resolver errors into the current form error state, removing entries that
30
+ * are no longer invalid according to the latest resolver result.
31
+ */
32
+ const mergeResolverErrors = (current, resolverErrors) => {
33
+ const next = {
34
+ ...current
35
+ };
36
+ Object.keys({
37
+ ...current,
38
+ ...resolverErrors
39
+ }).forEach(key => {
40
+ if (isValidError(resolverErrors[key])) {
41
+ next[key] = resolverErrors[key];
42
+ } else {
43
+ delete next[key];
44
+ }
45
+ });
46
+ return next;
47
+ };
48
+
22
49
  /**
23
50
  * Validate the form data and return a boolean.
24
51
  * The error message after verification is returned in the callback.
52
+ *
53
+ * When a `resolver` is provided and the resolver returns a Promise (async resolver),
54
+ * this method cannot resolve the result synchronously. In that case it returns `false`
55
+ * immediately and you should use `checkAsync()` instead.
25
56
  * @param callback
26
57
  */
27
58
  const check = useEventCallback(callback => {
59
+ if (resolver) {
60
+ const result = resolver(formValue || {});
61
+
62
+ // Async resolver: cannot handle synchronously
63
+ if (result instanceof Promise) {
64
+ if (process.env.NODE_ENV !== 'production') {
65
+ console.warn('[rsuite] The `resolver` provided to <Form> returns a Promise. ' + 'Use `checkAsync()` or rely on `onSubmit` for async validation.');
66
+ }
67
+ return false;
68
+ }
69
+ const {
70
+ errors
71
+ } = result;
72
+ const hasError = Object.keys(errors).length > 0;
73
+ setFormError(errors);
74
+ onCheck?.(errors);
75
+ callback?.(errors);
76
+ if (hasError) {
77
+ onError?.(errors);
78
+ }
79
+ return !hasError;
80
+ }
28
81
  const formError = {};
29
82
  let errorCount = 0;
30
83
  const model = getCombinedModel();
@@ -33,16 +86,16 @@ export default function useFormValidate(_formError, props) {
33
86
  const checkResult = type.check(value, formValue, key);
34
87
  if (checkResult.hasError === true) {
35
88
  errorCount += 1;
36
- formErrorObj[key] = (checkResult === null || checkResult === void 0 ? void 0 : checkResult.errorMessage) || checkResult;
89
+ formErrorObj[key] = checkResult?.errorMessage || checkResult;
37
90
  }
38
91
 
39
92
  // Check nested object
40
- if (type !== null && type !== void 0 && type.objectTypeSchemaSpec) {
93
+ if (type?.objectTypeSchemaSpec) {
41
94
  Object.entries(type.objectTypeSchemaSpec).forEach(([nestedKey, nestedType]) => {
42
95
  formErrorObj[key] = formErrorObj[key] || {
43
96
  object: {}
44
97
  };
45
- checkField(nestedKey, nestedType, value === null || value === void 0 ? void 0 : value[nestedKey], formErrorObj[key].object);
98
+ checkField(nestedKey, nestedType, value?.[nestedKey], formErrorObj[key].object);
46
99
  });
47
100
  }
48
101
  };
@@ -50,15 +103,44 @@ export default function useFormValidate(_formError, props) {
50
103
  checkField(key, type, formValue[key], formError);
51
104
  });
52
105
  setFormError(formError);
53
- onCheck === null || onCheck === void 0 || onCheck(formError);
54
- callback === null || callback === void 0 || callback(formError);
106
+ onCheck?.(formError);
107
+ callback?.(formError);
55
108
  if (errorCount > 0) {
56
- onError === null || onError === void 0 || onError(formError);
109
+ onError?.(formError);
57
110
  return false;
58
111
  }
59
112
  return true;
60
113
  });
61
114
  const checkFieldForNextValue = useEventCallback((fieldName, nextValue, callback) => {
115
+ if (resolver) {
116
+ const result = resolver(nextValue);
117
+ if (result instanceof Promise) {
118
+ if (process.env.NODE_ENV !== 'production') {
119
+ console.warn('[rsuite] The `resolver` provided to <Form> returns a Promise. ' + 'Use `checkAsync()` or `checkForFieldAsync()` for async validation.');
120
+ }
121
+ return false;
122
+ }
123
+ const {
124
+ errors
125
+ } = result;
126
+ const fieldError = errors[fieldName];
127
+ const hasFieldError = isValidError(fieldError);
128
+ // Merge resolver errors with existing errors, clearing fields that now pass
129
+ const nextFormError = mergeResolverErrors(realFormError, errors);
130
+ setFormError(nextFormError);
131
+ onCheck?.(nextFormError);
132
+ const callbackResult = {
133
+ hasError: hasFieldError,
134
+ errorMessage: fieldError
135
+ };
136
+ callback?.(hasFieldError ? callbackResult : {
137
+ hasError: false
138
+ });
139
+ if (Object.keys(nextFormError).length > 0) {
140
+ onError?.(nextFormError);
141
+ }
142
+ return !hasFieldError;
143
+ }
62
144
  const model = getCombinedModel();
63
145
  const resultOfCurrentField = model.checkForField(fieldName, nextValue, checkOptions);
64
146
  let nextFormError = {
@@ -72,10 +154,10 @@ export default function useFormValidate(_formError, props) {
72
154
  if (nestedField) {
73
155
  nextFormError = set(nextFormError, nameToPath(fieldName), resultOfCurrentField);
74
156
  setFormError(nextFormError);
75
- onCheck === null || onCheck === void 0 || onCheck(nextFormError);
76
- callback === null || callback === void 0 || callback(resultOfCurrentField);
157
+ onCheck?.(nextFormError);
158
+ callback?.(resultOfCurrentField);
77
159
  if (resultOfCurrentField.hasError) {
78
- onError === null || onError === void 0 || onError(nextFormError);
160
+ onError?.(nextFormError);
79
161
  }
80
162
  return !resultOfCurrentField.hasError;
81
163
  } else {
@@ -96,10 +178,10 @@ export default function useFormValidate(_formError, props) {
96
178
  }
97
179
  });
98
180
  setFormError(nextFormError);
99
- onCheck === null || onCheck === void 0 || onCheck(nextFormError);
100
- callback === null || callback === void 0 || callback(resultOfCurrentField);
181
+ onCheck?.(nextFormError);
182
+ callback?.(resultOfCurrentField);
101
183
  if (hasError) {
102
- onError === null || onError === void 0 || onError(nextFormError);
184
+ onError?.(nextFormError);
103
185
  }
104
186
  return !hasError;
105
187
  }
@@ -117,6 +199,22 @@ export default function useFormValidate(_formError, props) {
117
199
  * Check form data asynchronously and return a Promise
118
200
  */
119
201
  const checkAsync = useEventCallback(() => {
202
+ if (resolver) {
203
+ return Promise.resolve(resolver(formValue || {})).then(({
204
+ errors
205
+ }) => {
206
+ const hasError = Object.keys(errors).length > 0;
207
+ onCheck?.(errors);
208
+ setFormError(errors);
209
+ if (hasError) {
210
+ onError?.(errors);
211
+ }
212
+ return {
213
+ hasError,
214
+ formError: errors
215
+ };
216
+ });
217
+ }
120
218
  const promises = [];
121
219
  const keys = [];
122
220
  const model = getCombinedModel();
@@ -133,10 +231,10 @@ export default function useFormValidate(_formError, props) {
133
231
  formError[keys[i]] = values[i].errorMessage;
134
232
  }
135
233
  }
136
- onCheck === null || onCheck === void 0 || onCheck(formError);
234
+ onCheck?.(formError);
137
235
  setFormError(formError);
138
236
  if (errorCount > 0) {
139
- onError === null || onError === void 0 || onError(formError);
237
+ onError?.(formError);
140
238
  }
141
239
  return {
142
240
  hasError: errorCount > 0,
@@ -145,6 +243,24 @@ export default function useFormValidate(_formError, props) {
145
243
  });
146
244
  });
147
245
  const checkFieldAsyncForNextValue = useEventCallback((fieldName, nextValue) => {
246
+ if (resolver) {
247
+ return Promise.resolve(resolver(nextValue)).then(({
248
+ errors
249
+ }) => {
250
+ const fieldError = errors[fieldName];
251
+ const hasFieldError = isValidError(fieldError);
252
+ const nextFormError = mergeResolverErrors(realFormError, errors);
253
+ onCheck?.(nextFormError);
254
+ setFormError(nextFormError);
255
+ if (Object.keys(nextFormError).length > 0) {
256
+ onError?.(nextFormError);
257
+ }
258
+ return {
259
+ hasError: hasFieldError,
260
+ errorMessage: fieldError
261
+ };
262
+ });
263
+ }
148
264
  const model = getCombinedModel();
149
265
  return model.checkForFieldAsync(fieldName, nextValue, checkOptions).then(resultOfCurrentField => {
150
266
  let nextFormError = {
@@ -158,10 +274,10 @@ export default function useFormValidate(_formError, props) {
158
274
 
159
275
  if (nestedField) {
160
276
  nextFormError = set(nextFormError, nameToPath(fieldName), resultOfCurrentField);
161
- onCheck === null || onCheck === void 0 || onCheck(nextFormError);
277
+ onCheck?.(nextFormError);
162
278
  setFormError(nextFormError);
163
279
  if (resultOfCurrentField.hasError) {
164
- onError === null || onError === void 0 || onError(nextFormError);
280
+ onError?.(nextFormError);
165
281
  }
166
282
  return resultOfCurrentField;
167
283
  } else {
@@ -182,9 +298,9 @@ export default function useFormValidate(_formError, props) {
182
298
  }
183
299
  });
184
300
  setFormError(nextFormError);
185
- onCheck === null || onCheck === void 0 || onCheck(nextFormError);
301
+ onCheck?.(nextFormError);
186
302
  if (hasError) {
187
- onError === null || onError === void 0 || onError(nextFormError);
303
+ onError?.(nextFormError);
188
304
  }
189
305
  return resultOfCurrentField;
190
306
  }
@@ -206,7 +322,7 @@ export default function useFormValidate(_formError, props) {
206
322
  const formError = omit(realFormErrorRef.current, [nestedField ? nameToPath(name) : name]);
207
323
  realFormErrorRef.current = formError;
208
324
  setFormError(formError);
209
- onCheck === null || onCheck === void 0 || onCheck(formError);
325
+ onCheck?.(formError);
210
326
  return formError;
211
327
  }, [nestedField, onCheck, setFormError]);
212
328
  const cleanErrors = useEventCallback(() => {
@@ -1,4 +1,3 @@
1
- /// <reference types="lodash" />
2
1
  type RecordAny = Record<string, any>;
3
2
  interface UseFormValueProps<V = RecordAny> {
4
3
  formDefaultValue: V;
@@ -1,5 +1,6 @@
1
1
  import Form from './Form';
2
2
  export type { FormProps } from './Form';
3
3
  export type { FormInstance } from './hooks/useFormRef';
4
+ export type { Resolver, ResolverResult } from './resolvers';
4
5
  export { Form };
5
6
  export default Form;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The result returned by a validation resolver.
3
+ *
4
+ * @template E - The type of the form error map. Defaults to a record of string keys to any.
5
+ */
6
+ export interface ResolverResult<E = Record<string, any>> {
7
+ errors: E;
8
+ }
9
+ /**
10
+ * A resolver is a function that integrates third-party validation libraries
11
+ * (e.g. Yup, Zod, AJV, Joi, Valibot…) with the rsuite `Form` component.
12
+ *
13
+ * The resolver receives the current form values and an optional context object,
14
+ * and must return (or resolve to) a `ResolverResult` whose `errors` property is
15
+ * a plain object that maps field names to error messages / error objects.
16
+ *
17
+ * An **empty** `errors` object means the form is valid.
18
+ *
19
+ * @template V - The shape of the form values. Defaults to `Record<string, any>`.
20
+ * @template E - The shape of the error map. Defaults to `Record<string, any>`.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * // Yup example
25
+ * import * as yup from 'yup';
26
+ * import type { Resolver } from 'rsuite';
27
+ *
28
+ * const schema = yup.object({ name: yup.string().email('Invalid email').required() });
29
+ *
30
+ * const resolver: Resolver = async (formValue) => {
31
+ * try {
32
+ * await schema.validate(formValue, { abortEarly: false });
33
+ * return { errors: {} };
34
+ * } catch (e: any) {
35
+ * const errors: Record<string, string> = {};
36
+ * e.inner.forEach((err: yup.ValidationError) => {
37
+ * if (err.path) errors[err.path] = err.message;
38
+ * });
39
+ * return { errors };
40
+ * }
41
+ * };
42
+ *
43
+ * // Zod example
44
+ * import { z } from 'zod';
45
+ *
46
+ * const schema = z.object({ name: z.string().email('Invalid email') });
47
+ *
48
+ * const resolver: Resolver = (formValue) => {
49
+ * const result = schema.safeParse(formValue);
50
+ * if (result.success) return { errors: {} };
51
+ * const errors: Record<string, string> = {};
52
+ * result.error.issues.forEach(err => {
53
+ * if (err.path.length) errors[err.path[0]] = err.message;
54
+ * });
55
+ * return { errors };
56
+ * };
57
+ * ```
58
+ */
59
+ export type Resolver<V = Record<string, any>, E = Record<string, any>> = (formValue: V, context?: any) => ResolverResult<E> | Promise<ResolverResult<E>>;
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ export {};
@@ -70,9 +70,9 @@ const FormControl = forwardRef((props, ref) => {
70
70
  });
71
71
 
72
72
  // Combine props and context values
73
- const resolvedReadOnly = readOnly !== null && readOnly !== void 0 ? readOnly : contextReadOnly;
74
- const resolvedPlaintext = plaintext !== null && plaintext !== void 0 ? plaintext : contextPlaintext;
75
- const resolvedDisabled = disabled !== null && disabled !== void 0 ? disabled : contextDisabled;
73
+ const resolvedReadOnly = readOnly ?? contextReadOnly;
74
+ const resolvedPlaintext = plaintext ?? contextPlaintext;
75
+ const resolvedDisabled = disabled ?? contextDisabled;
76
76
  const {
77
77
  withPrefix,
78
78
  prefix
@@ -82,13 +82,13 @@ const FormControl = forwardRef((props, ref) => {
82
82
  // Handle onChange with both hook's implementation and prop callback
83
83
  const handleChange = (value, event) => {
84
84
  handleFieldChange(value, event);
85
- propsOnChange === null || propsOnChange === void 0 || propsOnChange(value, event);
85
+ propsOnChange?.(value, event);
86
86
  };
87
87
 
88
88
  // Handle onBlur with both hook's implementation and prop callback
89
89
  const handleBlur = event => {
90
90
  handleFieldBlur(); // onBlur doesn't take parameters in the hook
91
- propsOnBlur === null || propsOnBlur === void 0 || propsOnBlur(event);
91
+ propsOnBlur?.(event);
92
92
  };
93
93
 
94
94
  // Toggle component is a special case that uses `checked` and `defaultChecked` instead of `value` and `defaultValue` props.
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  export declare const FormGroupContext: React.Context<{
3
- controlId?: string | undefined;
3
+ controlId?: string;
4
4
  }>;
@@ -17,7 +17,7 @@ export function highlightText(text, props) {
17
17
  if (strArr[i]) {
18
18
  texts.push(strArr[i]);
19
19
  }
20
- if (highStrArr !== null && highStrArr !== void 0 && highStrArr[i]) {
20
+ if (highStrArr?.[i]) {
21
21
  texts.push(renderMark(highStrArr[i], i));
22
22
  }
23
23
  }
@@ -10,11 +10,10 @@ export function defaultRenderInput(props, ref) {
10
10
  }
11
11
  const pickers = ['DatePicker', 'DateRangePicker', 'TimePicker', 'TimeRangePicker', 'InputPicker', 'TagPicker', 'Cascader', 'MultiCascader', 'SelectPicker', 'CheckPicker', 'CheckTreePicker', 'TreePicker'];
12
12
  function getDisplayName(Component) {
13
- var _Component$type;
14
- if (typeof (Component === null || Component === void 0 ? void 0 : Component.type) === 'string') {
15
- return Component === null || Component === void 0 ? void 0 : Component.type;
13
+ if (typeof Component?.type === 'string') {
14
+ return Component?.type;
16
15
  }
17
- return (Component === null || Component === void 0 || (_Component$type = Component.type) === null || _Component$type === void 0 ? void 0 : _Component$type.displayName) || '';
16
+ return Component?.type?.displayName || '';
18
17
  }
19
18
  export function renderChildren(children, props, ref) {
20
19
  if (typeof children === 'function') {
@@ -34,8 +33,8 @@ export function renderChildren(children, props, ref) {
34
33
  ...rest,
35
34
  // Pass onBlur to the child component to automatically save or cancel after the focus event is processed.
36
35
  // Special handling in the Picker component, call onBlur when onExit and onClean
37
- onExit: createChainedFunction(() => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), onExit),
38
- onClean: createChainedFunction(() => onBlur === null || onBlur === void 0 ? void 0 : onBlur(), onClean),
36
+ onExit: createChainedFunction(() => onBlur?.(), onExit),
37
+ onClean: createChainedFunction(() => onBlur?.(), onClean),
39
38
  ref
40
39
  });
41
40
  }
@@ -23,40 +23,37 @@ const useEditState = props => {
23
23
  if (disabled) {
24
24
  return;
25
25
  }
26
- onClick === null || onClick === void 0 || onClick(event);
27
- onEdit === null || onEdit === void 0 || onEdit(event);
26
+ onClick?.(event);
27
+ onEdit?.(event);
28
28
  setIsEditing(true);
29
29
  setResetValue(value);
30
30
  });
31
31
  const handleFocus = useEventCallback(event => {
32
32
  if (disabled || isEditing) return;
33
- onFocus === null || onFocus === void 0 || onFocus(event);
33
+ onFocus?.(event);
34
34
  setIsEditing(true);
35
35
  setResetValue(value);
36
36
  });
37
37
  const handleChange = useEventCallback((value, event) => {
38
38
  setValue(value);
39
- onChange === null || onChange === void 0 || onChange(value, event);
39
+ onChange?.(value, event);
40
40
  });
41
41
  const handleCancel = useEventCallback(event => {
42
- var _event$stopPropagatio;
43
42
  setIsEditing(false);
44
43
  setValue(resetValue);
45
- onCancel === null || onCancel === void 0 || onCancel(event);
46
- event === null || event === void 0 || (_event$stopPropagatio = event.stopPropagation) === null || _event$stopPropagatio === void 0 || _event$stopPropagatio.call(event);
44
+ onCancel?.(event);
45
+ event?.stopPropagation?.();
47
46
  });
48
47
  const handleSave = useEventCallback(event => {
49
- var _event$stopPropagatio2;
50
48
  setIsEditing(false);
51
- onSave === null || onSave === void 0 || onSave(event);
52
- event === null || event === void 0 || (_event$stopPropagatio2 = event.stopPropagation) === null || _event$stopPropagatio2 === void 0 || _event$stopPropagatio2.call(event);
49
+ onSave?.(event);
50
+ event?.stopPropagation?.();
53
51
  });
54
52
  const handleKeyDown = useEventCallback(event => {
55
- var _event$target;
56
53
  if (isEditing) {
57
54
  switch (event.key) {
58
55
  case 'Enter':
59
- if (((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.tagName) === 'INPUT') {
56
+ if (event.target?.tagName === 'INPUT') {
60
57
  handleSave(event);
61
58
  }
62
59
  break;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { PickerHandle } from '../internals/Picker/types';
3
2
  interface FocusEventProps {
4
3
  isEditing: boolean;
@@ -9,38 +9,34 @@ const useFocusEvent = ({
9
9
  onSave,
10
10
  onCancel
11
11
  }) => {
12
- var _ref$current;
13
12
  const ref = useRef(null);
14
13
  const rootRef = useRef(null);
15
- const isPicker = ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.type) === RSUITE_PICKER_TYPE;
14
+ const isPicker = ref.current?.type === RSUITE_PICKER_TYPE;
16
15
  const focus = () => {
17
16
  if (isPicker) {
18
17
  setTimeout(() => {
19
- var _picker$target, _picker$target$focus, _picker$open;
20
18
  const picker = ref.current;
21
19
  // Auto focus the search input
22
- picker === null || picker === void 0 || (_picker$target = picker.target) === null || _picker$target === void 0 || (_picker$target$focus = _picker$target.focus) === null || _picker$target$focus === void 0 || _picker$target$focus.call(_picker$target);
20
+ picker?.target?.focus?.();
23
21
 
24
22
  // Open the picker
25
- picker === null || picker === void 0 || (_picker$open = picker.open) === null || _picker$open === void 0 || _picker$open.call(picker);
23
+ picker?.open?.();
26
24
  }, 100);
27
25
  } else {
28
- var _ref$current2, _ref$current2$focus;
29
- (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || (_ref$current2$focus = _ref$current2.focus) === null || _ref$current2$focus === void 0 || _ref$current2$focus.call(_ref$current2);
26
+ ref.current?.focus?.();
30
27
  }
31
28
  };
32
29
  const handleBlur = useEventCallback(event => {
33
30
  if (event) {
34
- var _event$relatedTarget;
35
- const relatedTarget = (_event$relatedTarget = event.relatedTarget) !== null && _event$relatedTarget !== void 0 ? _event$relatedTarget : ownerDocument(event.currentTarget).activeElement;
31
+ const relatedTarget = event.relatedTarget ?? ownerDocument(event.currentTarget).activeElement;
36
32
  if (rootRef.current && contains(rootRef.current, relatedTarget)) {
37
33
  return;
38
34
  }
39
35
  }
40
36
  if (stateOnBlur === 'save') {
41
- onSave === null || onSave === void 0 || onSave(event);
37
+ onSave?.(event);
42
38
  } else if (stateOnBlur === 'cancel') {
43
- onCancel === null || onCancel === void 0 || onCancel(event);
39
+ onCancel?.(event);
44
40
  }
45
41
  });
46
42
  useIsomorphicLayoutEffect(() => {
@@ -18,7 +18,7 @@ const Input = forwardRef((props, ref) => {
18
18
  const {
19
19
  type = 'text',
20
20
  htmlSize,
21
- size = (inputGroup === null || inputGroup === void 0 ? void 0 : inputGroup.size) || 'md',
21
+ size = inputGroup?.size || 'md',
22
22
  classPrefix = 'input',
23
23
  ...rest
24
24
  } = propsWithDefaults;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
+ import type { Size } from '../internals/types';
2
3
  export declare const InputGroupContext: React.Context<{
3
4
  onFocus: () => void;
4
5
  onBlur: () => void;
5
- size?: "xs" | "sm" | "md" | "lg" | "xl" | undefined;
6
+ size?: Size;
6
7
  } | null>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { NumberInputProps as InputNumberProps } from '../NumberInput';
3
2
  /**
4
3
  * The `InputNumber` component is used to enter a numerical value.
@@ -50,7 +50,7 @@ const useInputWidth = (props, sizerRef, placeholderRef) => {
50
50
  }
51
51
  if (width !== inputWidth) {
52
52
  setInputWidth(width);
53
- onAutosize === null || onAutosize === void 0 || onAutosize(width);
53
+ onAutosize?.(width);
54
54
  }
55
55
  }, [minWidth, placeholder, inputWidth, value, placeholderRef, sizerRef, onAutosize]);
56
56
  return inputWidth;