rsuite 5.47.0 → 5.48.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 (530) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/DateInput/package.json +7 -0
  3. package/cjs/Affix/Affix.d.ts +6 -0
  4. package/cjs/Affix/Affix.js +7 -0
  5. package/cjs/Animation/Bounce.d.ts +4 -0
  6. package/cjs/Animation/Bounce.js +4 -0
  7. package/cjs/Animation/Collapse.d.ts +4 -0
  8. package/cjs/Animation/Collapse.js +5 -0
  9. package/cjs/Animation/Fade.d.ts +4 -0
  10. package/cjs/Animation/Fade.js +4 -0
  11. package/cjs/Animation/Slide.d.ts +4 -0
  12. package/cjs/Animation/Slide.js +4 -0
  13. package/cjs/Animation/Transition.d.ts +4 -0
  14. package/cjs/Animation/Transition.js +4 -0
  15. package/cjs/AutoComplete/AutoComplete.d.ts +3 -0
  16. package/cjs/AutoComplete/AutoComplete.js +3 -0
  17. package/cjs/Avatar/Avatar.d.ts +4 -0
  18. package/cjs/Avatar/Avatar.js +4 -0
  19. package/cjs/AvatarGroup/AvatarGroup.d.ts +4 -0
  20. package/cjs/AvatarGroup/AvatarGroup.js +5 -0
  21. package/cjs/Badge/Badge.d.ts +4 -0
  22. package/cjs/Badge/Badge.js +4 -0
  23. package/cjs/Breadcrumb/Breadcrumb.d.ts +4 -0
  24. package/cjs/Breadcrumb/Breadcrumb.js +4 -0
  25. package/cjs/Breadcrumb/BreadcrumbItem.d.ts +4 -0
  26. package/cjs/Breadcrumb/BreadcrumbItem.js +4 -0
  27. package/cjs/Button/Button.d.ts +4 -0
  28. package/cjs/Button/Button.js +4 -0
  29. package/cjs/ButtonGroup/ButtonGroup.d.ts +4 -0
  30. package/cjs/ButtonGroup/ButtonGroup.js +4 -0
  31. package/cjs/ButtonToolbar/ButtonToolbar.d.ts +4 -0
  32. package/cjs/ButtonToolbar/ButtonToolbar.js +4 -0
  33. package/cjs/Calendar/Calendar.d.ts +4 -0
  34. package/cjs/Calendar/Calendar.js +4 -0
  35. package/cjs/Carousel/Carousel.d.ts +4 -0
  36. package/cjs/Carousel/Carousel.js +4 -0
  37. package/cjs/Cascader/Cascader.d.ts +4 -0
  38. package/cjs/Cascader/Cascader.js +5 -0
  39. package/cjs/CheckPicker/CheckPicker.d.ts +4 -0
  40. package/cjs/CheckPicker/CheckPicker.js +4 -0
  41. package/cjs/CheckTree/index.d.ts +4 -0
  42. package/cjs/CheckTree/index.js +4 -0
  43. package/cjs/CheckTreePicker/CheckTreePicker.d.ts +5 -0
  44. package/cjs/CheckTreePicker/CheckTreePicker.js +6 -0
  45. package/cjs/Checkbox/Checkbox.d.ts +4 -0
  46. package/cjs/Checkbox/Checkbox.js +4 -0
  47. package/cjs/CheckboxGroup/CheckboxGroup.d.ts +4 -0
  48. package/cjs/CheckboxGroup/CheckboxGroup.js +4 -0
  49. package/cjs/Col/Col.d.ts +4 -0
  50. package/cjs/Col/Col.js +4 -0
  51. package/cjs/Container/Container.d.ts +4 -0
  52. package/cjs/Container/Container.js +4 -0
  53. package/cjs/Content/Content.d.ts +3 -0
  54. package/cjs/Content/Content.js +3 -0
  55. package/cjs/CustomProvider/CustomProvider.d.ts +5 -0
  56. package/cjs/CustomProvider/CustomProvider.js +6 -0
  57. package/cjs/DOMHelper/index.d.ts +4 -0
  58. package/cjs/DOMHelper/index.js +4 -0
  59. package/cjs/DateInput/DateField.d.ts +180 -0
  60. package/cjs/DateInput/DateField.js +151 -0
  61. package/cjs/DateInput/DateInput.d.ts +18 -0
  62. package/cjs/DateInput/DateInput.js +222 -0
  63. package/cjs/DateInput/index.d.ts +3 -0
  64. package/cjs/DateInput/index.js +9 -0
  65. package/cjs/DateInput/useDateInputState.d.ts +165 -0
  66. package/cjs/DateInput/useDateInputState.js +105 -0
  67. package/cjs/DateInput/utils.d.ts +41 -0
  68. package/cjs/DateInput/utils.js +159 -0
  69. package/cjs/DatePicker/DatePicker.d.ts +5 -0
  70. package/cjs/DatePicker/DatePicker.js +5 -0
  71. package/cjs/DateRangePicker/DateRangePicker.d.ts +5 -0
  72. package/cjs/DateRangePicker/DateRangePicker.js +5 -0
  73. package/cjs/Divider/Divider.d.ts +4 -0
  74. package/cjs/Divider/Divider.js +4 -0
  75. package/cjs/Drawer/Drawer.d.ts +4 -0
  76. package/cjs/Drawer/Drawer.js +4 -0
  77. package/cjs/Dropdown/Dropdown.d.ts +6 -3
  78. package/cjs/Dropdown/Dropdown.js +6 -3
  79. package/cjs/Dropdown/DropdownItem.d.ts +3 -3
  80. package/cjs/Dropdown/DropdownItem.js +3 -3
  81. package/cjs/Dropdown/DropdownMenu.d.ts +3 -3
  82. package/cjs/Dropdown/DropdownMenu.js +3 -3
  83. package/cjs/Dropdown/DropdownSeparator.d.ts +1 -1
  84. package/cjs/Dropdown/DropdownSeparator.js +1 -1
  85. package/cjs/FlexboxGrid/FlexboxGrid.d.ts +4 -0
  86. package/cjs/FlexboxGrid/FlexboxGrid.js +4 -0
  87. package/cjs/FlexboxGrid/FlexboxGridItem.d.ts +4 -0
  88. package/cjs/FlexboxGrid/FlexboxGridItem.js +4 -0
  89. package/cjs/Footer/Footer.d.ts +4 -0
  90. package/cjs/Footer/Footer.js +4 -0
  91. package/cjs/Form/Form.d.ts +4 -0
  92. package/cjs/Form/Form.js +4 -0
  93. package/cjs/FormControl/FormControl.d.ts +4 -0
  94. package/cjs/FormControl/FormControl.js +4 -0
  95. package/cjs/FormControlLabel/FormControlLabel.d.ts +4 -0
  96. package/cjs/FormControlLabel/FormControlLabel.js +4 -0
  97. package/cjs/FormErrorMessage/FormErrorMessage.d.ts +4 -0
  98. package/cjs/FormErrorMessage/FormErrorMessage.js +4 -0
  99. package/cjs/FormGroup/FormGroup.d.ts +4 -0
  100. package/cjs/FormGroup/FormGroup.js +5 -0
  101. package/cjs/FormHelpText/FormHelpText.d.ts +4 -0
  102. package/cjs/FormHelpText/FormHelpText.js +4 -0
  103. package/cjs/Grid/Grid.d.ts +4 -0
  104. package/cjs/Grid/Grid.js +4 -0
  105. package/cjs/Header/Header.d.ts +4 -0
  106. package/cjs/Header/Header.js +4 -0
  107. package/cjs/IconButton/IconButton.d.ts +4 -0
  108. package/cjs/IconButton/IconButton.js +4 -0
  109. package/cjs/Input/Input.d.ts +4 -0
  110. package/cjs/Input/Input.js +4 -0
  111. package/cjs/InputGroup/InputGroup.d.ts +4 -0
  112. package/cjs/InputGroup/InputGroup.js +4 -0
  113. package/cjs/InputGroup/InputGroupAddon.d.ts +4 -0
  114. package/cjs/InputGroup/InputGroupAddon.js +4 -0
  115. package/cjs/InputGroup/InputGroupButton.d.ts +4 -0
  116. package/cjs/InputGroup/InputGroupButton.js +4 -0
  117. package/cjs/InputNumber/InputNumber.d.ts +4 -0
  118. package/cjs/InputNumber/InputNumber.js +5 -0
  119. package/cjs/InputPicker/InputPicker.d.ts +5 -0
  120. package/cjs/InputPicker/InputPicker.js +5 -0
  121. package/cjs/List/List.d.ts +4 -0
  122. package/cjs/List/List.js +4 -0
  123. package/cjs/List/ListItem.d.ts +4 -0
  124. package/cjs/List/ListItem.js +4 -0
  125. package/cjs/Loader/Loader.d.ts +4 -0
  126. package/cjs/Loader/Loader.js +4 -0
  127. package/cjs/MaskedInput/TextMask.d.ts +4 -0
  128. package/cjs/MaskedInput/TextMask.js +5 -0
  129. package/cjs/MaskedInput/createTextMaskInputElement.js +6 -16
  130. package/cjs/Message/Message.d.ts +4 -0
  131. package/cjs/Message/Message.js +4 -0
  132. package/cjs/Modal/Modal.d.ts +4 -0
  133. package/cjs/Modal/Modal.js +4 -0
  134. package/cjs/MultiCascader/MultiCascader.d.ts +4 -0
  135. package/cjs/MultiCascader/MultiCascader.js +5 -0
  136. package/cjs/Nav/Nav.d.ts +4 -0
  137. package/cjs/Nav/Nav.js +4 -0
  138. package/cjs/Nav/NavDropdown.d.ts +2 -1
  139. package/cjs/Nav/NavDropdown.js +2 -1
  140. package/cjs/Nav/NavItem.d.ts +6 -3
  141. package/cjs/Nav/NavItem.js +6 -3
  142. package/cjs/Nav/NavMenu.d.ts +6 -3
  143. package/cjs/Nav/NavMenu.js +6 -3
  144. package/cjs/Navbar/Navbar.d.ts +4 -0
  145. package/cjs/Navbar/Navbar.js +4 -0
  146. package/cjs/Notification/Notification.d.ts +5 -0
  147. package/cjs/Notification/Notification.js +5 -0
  148. package/cjs/Overlay/Overlay.d.ts +4 -0
  149. package/cjs/Overlay/Overlay.js +5 -0
  150. package/cjs/Overlay/OverlayTrigger.d.ts +4 -0
  151. package/cjs/Overlay/OverlayTrigger.js +16 -11
  152. package/cjs/Overlay/Position.d.ts +4 -0
  153. package/cjs/Overlay/Position.js +4 -0
  154. package/cjs/Pagination/Pagination.d.ts +5 -0
  155. package/cjs/Pagination/Pagination.js +5 -0
  156. package/cjs/Panel/Panel.d.ts +4 -0
  157. package/cjs/Panel/Panel.js +4 -0
  158. package/cjs/PanelGroup/PanelGroup.d.ts +4 -0
  159. package/cjs/PanelGroup/PanelGroup.js +5 -0
  160. package/cjs/Placeholder/Placeholder.d.ts +4 -0
  161. package/cjs/Placeholder/Placeholder.js +4 -0
  162. package/cjs/Placeholder/PlaceholderGraph.d.ts +4 -0
  163. package/cjs/Placeholder/PlaceholderGraph.js +4 -0
  164. package/cjs/Placeholder/PlaceholderGrid.d.ts +4 -0
  165. package/cjs/Placeholder/PlaceholderGrid.js +4 -0
  166. package/cjs/Placeholder/PlaceholderParagraph.d.ts +4 -0
  167. package/cjs/Placeholder/PlaceholderParagraph.js +4 -0
  168. package/cjs/Plaintext/Plaintext.d.ts +2 -1
  169. package/cjs/Plaintext/Plaintext.js +5 -2
  170. package/cjs/Popover/Popover.d.ts +4 -0
  171. package/cjs/Popover/Popover.js +4 -0
  172. package/cjs/Progress/Progress.d.ts +4 -0
  173. package/cjs/Progress/Progress.js +4 -0
  174. package/cjs/Progress/ProgressCircle.d.ts +4 -0
  175. package/cjs/Progress/ProgressCircle.js +4 -0
  176. package/cjs/Progress/ProgressLine.d.ts +4 -0
  177. package/cjs/Progress/ProgressLine.js +4 -0
  178. package/cjs/Radio/Radio.d.ts +4 -0
  179. package/cjs/Radio/Radio.js +4 -0
  180. package/cjs/RadioGroup/RadioGroup.d.ts +4 -0
  181. package/cjs/RadioGroup/RadioGroup.js +5 -0
  182. package/cjs/RadioTileGroup/RadioTileGroup.d.ts +5 -0
  183. package/cjs/RadioTileGroup/RadioTileGroup.js +6 -0
  184. package/cjs/RangeSlider/RangeSlider.d.ts +4 -0
  185. package/cjs/RangeSlider/RangeSlider.js +5 -0
  186. package/cjs/Rate/Rate.d.ts +4 -0
  187. package/cjs/Rate/Rate.js +4 -0
  188. package/cjs/Ripple/Ripple.d.ts +4 -0
  189. package/cjs/Ripple/Ripple.js +5 -0
  190. package/cjs/Row/Row.d.ts +4 -0
  191. package/cjs/Row/Row.js +4 -0
  192. package/cjs/SafeAnchor/SafeAnchor.d.ts +4 -0
  193. package/cjs/SafeAnchor/SafeAnchor.js +5 -0
  194. package/cjs/Schema/Schema.d.ts +6 -0
  195. package/cjs/Schema/Schema.js +6 -0
  196. package/cjs/SelectPicker/SelectPicker.d.ts +4 -0
  197. package/cjs/SelectPicker/SelectPicker.js +4 -0
  198. package/cjs/Sidebar/Sidebar.d.ts +4 -0
  199. package/cjs/Sidebar/Sidebar.js +4 -0
  200. package/cjs/Sidenav/Sidenav.d.ts +4 -0
  201. package/cjs/Sidenav/Sidenav.js +5 -0
  202. package/cjs/Sidenav/SidenavBody.d.ts +5 -0
  203. package/cjs/Sidenav/SidenavBody.js +5 -0
  204. package/cjs/Sidenav/SidenavHeader.d.ts +5 -0
  205. package/cjs/Sidenav/SidenavHeader.js +5 -0
  206. package/cjs/Slider/Slider.d.ts +5 -0
  207. package/cjs/Slider/Slider.js +6 -0
  208. package/cjs/Stack/Stack.d.ts +6 -0
  209. package/cjs/Stack/Stack.js +6 -0
  210. package/cjs/Stack/StackItem.d.ts +5 -0
  211. package/cjs/Stack/StackItem.js +5 -0
  212. package/cjs/Steps/StepItem.d.ts +5 -0
  213. package/cjs/Steps/StepItem.js +5 -0
  214. package/cjs/Steps/Steps.d.ts +5 -0
  215. package/cjs/Steps/Steps.js +5 -0
  216. package/cjs/Table/Table.d.ts +19 -2
  217. package/cjs/Table/Table.js +20 -1
  218. package/cjs/Tag/Tag.d.ts +6 -0
  219. package/cjs/Tag/Tag.js +6 -0
  220. package/cjs/TagGroup/TagGroup.d.ts +5 -0
  221. package/cjs/TagGroup/TagGroup.js +5 -0
  222. package/cjs/TagInput/index.d.ts +5 -0
  223. package/cjs/TagInput/index.js +5 -0
  224. package/cjs/TagPicker/index.d.ts +2 -1
  225. package/cjs/TagPicker/index.js +2 -1
  226. package/cjs/Timeline/Timeline.d.ts +5 -0
  227. package/cjs/Timeline/Timeline.js +5 -0
  228. package/cjs/Timeline/TimelineItem.d.ts +5 -0
  229. package/cjs/Timeline/TimelineItem.js +5 -0
  230. package/cjs/Toggle/Toggle.d.ts +5 -0
  231. package/cjs/Toggle/Toggle.js +5 -0
  232. package/cjs/Tooltip/Tooltip.d.ts +5 -0
  233. package/cjs/Tooltip/Tooltip.js +5 -0
  234. package/cjs/Tree/Tree.d.ts +5 -0
  235. package/cjs/Tree/Tree.js +5 -0
  236. package/cjs/TreePicker/TreePicker.d.ts +5 -0
  237. package/cjs/TreePicker/TreePicker.js +6 -0
  238. package/cjs/Uploader/Uploader.d.ts +5 -0
  239. package/cjs/Uploader/Uploader.js +6 -0
  240. package/cjs/Whisper/Whisper.d.ts +6 -0
  241. package/cjs/Whisper/Whisper.js +6 -0
  242. package/cjs/Windowing/AutoSizer.d.ts +5 -0
  243. package/cjs/Windowing/AutoSizer.js +5 -0
  244. package/cjs/Windowing/List.d.ts +6 -1
  245. package/cjs/Windowing/List.js +5 -0
  246. package/cjs/index.d.ts +3 -0
  247. package/cjs/index.js +6 -2
  248. package/cjs/toaster/toaster.d.ts +9 -7
  249. package/cjs/toaster/useToaster.d.ts +19 -1
  250. package/cjs/toaster/useToaster.js +19 -1
  251. package/cjs/useMediaQuery/index.d.ts +2 -0
  252. package/cjs/useMediaQuery/index.js +9 -0
  253. package/cjs/useMediaQuery/useMediaQuery.d.ts +23 -0
  254. package/cjs/useMediaQuery/useMediaQuery.js +123 -0
  255. package/cjs/utils/BrowserDetection.d.ts +1 -0
  256. package/cjs/utils/BrowserDetection.js +5 -1
  257. package/cjs/utils/dateUtils.d.ts +6 -0
  258. package/cjs/utils/dateUtils.js +13 -1
  259. package/cjs/utils/index.d.ts +1 -0
  260. package/cjs/utils/index.js +4 -1
  261. package/cjs/utils/safeSetSelection.d.ts +2 -0
  262. package/cjs/utils/safeSetSelection.js +21 -0
  263. package/cjs/utils/treeUtils.d.ts +2 -2
  264. package/dist/rsuite.js +336 -122
  265. package/dist/rsuite.js.map +1 -1
  266. package/dist/rsuite.min.js +1 -1
  267. package/dist/rsuite.min.js.map +1 -1
  268. package/esm/Affix/Affix.d.ts +6 -0
  269. package/esm/Affix/Affix.js +7 -0
  270. package/esm/Animation/Bounce.d.ts +4 -0
  271. package/esm/Animation/Bounce.js +4 -0
  272. package/esm/Animation/Collapse.d.ts +4 -0
  273. package/esm/Animation/Collapse.js +5 -0
  274. package/esm/Animation/Fade.d.ts +4 -0
  275. package/esm/Animation/Fade.js +4 -0
  276. package/esm/Animation/Slide.d.ts +4 -0
  277. package/esm/Animation/Slide.js +4 -0
  278. package/esm/Animation/Transition.d.ts +4 -0
  279. package/esm/Animation/Transition.js +4 -0
  280. package/esm/AutoComplete/AutoComplete.d.ts +3 -0
  281. package/esm/AutoComplete/AutoComplete.js +3 -0
  282. package/esm/Avatar/Avatar.d.ts +4 -0
  283. package/esm/Avatar/Avatar.js +4 -0
  284. package/esm/AvatarGroup/AvatarGroup.d.ts +4 -0
  285. package/esm/AvatarGroup/AvatarGroup.js +5 -0
  286. package/esm/Badge/Badge.d.ts +4 -0
  287. package/esm/Badge/Badge.js +4 -0
  288. package/esm/Breadcrumb/Breadcrumb.d.ts +4 -0
  289. package/esm/Breadcrumb/Breadcrumb.js +4 -0
  290. package/esm/Breadcrumb/BreadcrumbItem.d.ts +4 -0
  291. package/esm/Breadcrumb/BreadcrumbItem.js +4 -0
  292. package/esm/Button/Button.d.ts +4 -0
  293. package/esm/Button/Button.js +4 -0
  294. package/esm/ButtonGroup/ButtonGroup.d.ts +4 -0
  295. package/esm/ButtonGroup/ButtonGroup.js +4 -0
  296. package/esm/ButtonToolbar/ButtonToolbar.d.ts +4 -0
  297. package/esm/ButtonToolbar/ButtonToolbar.js +4 -0
  298. package/esm/Calendar/Calendar.d.ts +4 -0
  299. package/esm/Calendar/Calendar.js +4 -0
  300. package/esm/Carousel/Carousel.d.ts +4 -0
  301. package/esm/Carousel/Carousel.js +4 -0
  302. package/esm/Cascader/Cascader.d.ts +4 -0
  303. package/esm/Cascader/Cascader.js +5 -0
  304. package/esm/CheckPicker/CheckPicker.d.ts +4 -0
  305. package/esm/CheckPicker/CheckPicker.js +4 -0
  306. package/esm/CheckTree/index.d.ts +4 -0
  307. package/esm/CheckTree/index.js +4 -0
  308. package/esm/CheckTreePicker/CheckTreePicker.d.ts +5 -0
  309. package/esm/CheckTreePicker/CheckTreePicker.js +6 -0
  310. package/esm/Checkbox/Checkbox.d.ts +4 -0
  311. package/esm/Checkbox/Checkbox.js +4 -0
  312. package/esm/CheckboxGroup/CheckboxGroup.d.ts +4 -0
  313. package/esm/CheckboxGroup/CheckboxGroup.js +4 -0
  314. package/esm/Col/Col.d.ts +4 -0
  315. package/esm/Col/Col.js +4 -0
  316. package/esm/Container/Container.d.ts +4 -0
  317. package/esm/Container/Container.js +4 -0
  318. package/esm/Content/Content.d.ts +3 -0
  319. package/esm/Content/Content.js +3 -0
  320. package/esm/CustomProvider/CustomProvider.d.ts +5 -0
  321. package/esm/CustomProvider/CustomProvider.js +6 -0
  322. package/esm/DOMHelper/index.d.ts +4 -0
  323. package/esm/DOMHelper/index.js +5 -0
  324. package/esm/DateInput/DateField.d.ts +180 -0
  325. package/esm/DateInput/DateField.js +144 -0
  326. package/esm/DateInput/DateInput.d.ts +18 -0
  327. package/esm/DateInput/DateInput.js +215 -0
  328. package/esm/DateInput/index.d.ts +3 -0
  329. package/esm/DateInput/index.js +3 -0
  330. package/esm/DateInput/useDateInputState.d.ts +165 -0
  331. package/esm/DateInput/useDateInputState.js +99 -0
  332. package/esm/DateInput/utils.d.ts +41 -0
  333. package/esm/DateInput/utils.js +151 -0
  334. package/esm/DatePicker/DatePicker.d.ts +5 -0
  335. package/esm/DatePicker/DatePicker.js +5 -0
  336. package/esm/DateRangePicker/DateRangePicker.d.ts +5 -0
  337. package/esm/DateRangePicker/DateRangePicker.js +5 -0
  338. package/esm/Divider/Divider.d.ts +4 -0
  339. package/esm/Divider/Divider.js +4 -0
  340. package/esm/Drawer/Drawer.d.ts +4 -0
  341. package/esm/Drawer/Drawer.js +4 -0
  342. package/esm/Dropdown/Dropdown.d.ts +6 -3
  343. package/esm/Dropdown/Dropdown.js +6 -3
  344. package/esm/Dropdown/DropdownItem.d.ts +3 -3
  345. package/esm/Dropdown/DropdownItem.js +3 -3
  346. package/esm/Dropdown/DropdownMenu.d.ts +3 -3
  347. package/esm/Dropdown/DropdownMenu.js +3 -3
  348. package/esm/Dropdown/DropdownSeparator.d.ts +1 -1
  349. package/esm/Dropdown/DropdownSeparator.js +1 -1
  350. package/esm/FlexboxGrid/FlexboxGrid.d.ts +4 -0
  351. package/esm/FlexboxGrid/FlexboxGrid.js +4 -0
  352. package/esm/FlexboxGrid/FlexboxGridItem.d.ts +4 -0
  353. package/esm/FlexboxGrid/FlexboxGridItem.js +4 -0
  354. package/esm/Footer/Footer.d.ts +4 -0
  355. package/esm/Footer/Footer.js +4 -0
  356. package/esm/Form/Form.d.ts +4 -0
  357. package/esm/Form/Form.js +4 -0
  358. package/esm/FormControl/FormControl.d.ts +4 -0
  359. package/esm/FormControl/FormControl.js +4 -0
  360. package/esm/FormControlLabel/FormControlLabel.d.ts +4 -0
  361. package/esm/FormControlLabel/FormControlLabel.js +4 -0
  362. package/esm/FormErrorMessage/FormErrorMessage.d.ts +4 -0
  363. package/esm/FormErrorMessage/FormErrorMessage.js +4 -0
  364. package/esm/FormGroup/FormGroup.d.ts +4 -0
  365. package/esm/FormGroup/FormGroup.js +5 -0
  366. package/esm/FormHelpText/FormHelpText.d.ts +4 -0
  367. package/esm/FormHelpText/FormHelpText.js +4 -0
  368. package/esm/Grid/Grid.d.ts +4 -0
  369. package/esm/Grid/Grid.js +4 -0
  370. package/esm/Header/Header.d.ts +4 -0
  371. package/esm/Header/Header.js +4 -0
  372. package/esm/IconButton/IconButton.d.ts +4 -0
  373. package/esm/IconButton/IconButton.js +4 -0
  374. package/esm/Input/Input.d.ts +4 -0
  375. package/esm/Input/Input.js +4 -0
  376. package/esm/InputGroup/InputGroup.d.ts +4 -0
  377. package/esm/InputGroup/InputGroup.js +4 -0
  378. package/esm/InputGroup/InputGroupAddon.d.ts +4 -0
  379. package/esm/InputGroup/InputGroupAddon.js +4 -0
  380. package/esm/InputGroup/InputGroupButton.d.ts +4 -0
  381. package/esm/InputGroup/InputGroupButton.js +5 -0
  382. package/esm/InputNumber/InputNumber.d.ts +4 -0
  383. package/esm/InputNumber/InputNumber.js +5 -0
  384. package/esm/InputPicker/InputPicker.d.ts +5 -0
  385. package/esm/InputPicker/InputPicker.js +5 -0
  386. package/esm/List/List.d.ts +4 -0
  387. package/esm/List/List.js +4 -0
  388. package/esm/List/ListItem.d.ts +4 -0
  389. package/esm/List/ListItem.js +4 -0
  390. package/esm/Loader/Loader.d.ts +4 -0
  391. package/esm/Loader/Loader.js +4 -0
  392. package/esm/MaskedInput/TextMask.d.ts +4 -0
  393. package/esm/MaskedInput/TextMask.js +5 -0
  394. package/esm/MaskedInput/createTextMaskInputElement.js +6 -16
  395. package/esm/Message/Message.d.ts +4 -0
  396. package/esm/Message/Message.js +4 -0
  397. package/esm/Modal/Modal.d.ts +4 -0
  398. package/esm/Modal/Modal.js +4 -0
  399. package/esm/MultiCascader/MultiCascader.d.ts +4 -0
  400. package/esm/MultiCascader/MultiCascader.js +5 -0
  401. package/esm/Nav/Nav.d.ts +4 -0
  402. package/esm/Nav/Nav.js +4 -0
  403. package/esm/Nav/NavDropdown.d.ts +2 -1
  404. package/esm/Nav/NavDropdown.js +2 -1
  405. package/esm/Nav/NavItem.d.ts +6 -3
  406. package/esm/Nav/NavItem.js +6 -3
  407. package/esm/Nav/NavMenu.d.ts +6 -3
  408. package/esm/Nav/NavMenu.js +6 -3
  409. package/esm/Navbar/Navbar.d.ts +4 -0
  410. package/esm/Navbar/Navbar.js +4 -0
  411. package/esm/Notification/Notification.d.ts +5 -0
  412. package/esm/Notification/Notification.js +5 -0
  413. package/esm/Overlay/Overlay.d.ts +4 -0
  414. package/esm/Overlay/Overlay.js +5 -0
  415. package/esm/Overlay/OverlayTrigger.d.ts +4 -0
  416. package/esm/Overlay/OverlayTrigger.js +16 -11
  417. package/esm/Overlay/Position.d.ts +4 -0
  418. package/esm/Overlay/Position.js +4 -0
  419. package/esm/Pagination/Pagination.d.ts +5 -0
  420. package/esm/Pagination/Pagination.js +5 -0
  421. package/esm/Panel/Panel.d.ts +4 -0
  422. package/esm/Panel/Panel.js +4 -0
  423. package/esm/PanelGroup/PanelGroup.d.ts +4 -0
  424. package/esm/PanelGroup/PanelGroup.js +5 -0
  425. package/esm/Placeholder/Placeholder.d.ts +4 -0
  426. package/esm/Placeholder/Placeholder.js +4 -0
  427. package/esm/Placeholder/PlaceholderGraph.d.ts +4 -0
  428. package/esm/Placeholder/PlaceholderGraph.js +4 -0
  429. package/esm/Placeholder/PlaceholderGrid.d.ts +4 -0
  430. package/esm/Placeholder/PlaceholderGrid.js +4 -0
  431. package/esm/Placeholder/PlaceholderParagraph.d.ts +4 -0
  432. package/esm/Placeholder/PlaceholderParagraph.js +4 -0
  433. package/esm/Plaintext/Plaintext.d.ts +2 -1
  434. package/esm/Plaintext/Plaintext.js +5 -2
  435. package/esm/Popover/Popover.d.ts +4 -0
  436. package/esm/Popover/Popover.js +4 -0
  437. package/esm/Progress/Progress.d.ts +4 -0
  438. package/esm/Progress/Progress.js +4 -0
  439. package/esm/Progress/ProgressCircle.d.ts +4 -0
  440. package/esm/Progress/ProgressCircle.js +4 -0
  441. package/esm/Progress/ProgressLine.d.ts +4 -0
  442. package/esm/Progress/ProgressLine.js +4 -0
  443. package/esm/Radio/Radio.d.ts +4 -0
  444. package/esm/Radio/Radio.js +4 -0
  445. package/esm/RadioGroup/RadioGroup.d.ts +4 -0
  446. package/esm/RadioGroup/RadioGroup.js +5 -0
  447. package/esm/RadioTileGroup/RadioTileGroup.d.ts +5 -0
  448. package/esm/RadioTileGroup/RadioTileGroup.js +6 -0
  449. package/esm/RangeSlider/RangeSlider.d.ts +4 -0
  450. package/esm/RangeSlider/RangeSlider.js +5 -0
  451. package/esm/Rate/Rate.d.ts +4 -0
  452. package/esm/Rate/Rate.js +4 -0
  453. package/esm/Ripple/Ripple.d.ts +4 -0
  454. package/esm/Ripple/Ripple.js +5 -0
  455. package/esm/Row/Row.d.ts +4 -0
  456. package/esm/Row/Row.js +4 -0
  457. package/esm/SafeAnchor/SafeAnchor.d.ts +4 -0
  458. package/esm/SafeAnchor/SafeAnchor.js +5 -0
  459. package/esm/Schema/Schema.d.ts +6 -0
  460. package/esm/Schema/Schema.js +7 -0
  461. package/esm/SelectPicker/SelectPicker.d.ts +4 -0
  462. package/esm/SelectPicker/SelectPicker.js +4 -0
  463. package/esm/Sidebar/Sidebar.d.ts +4 -0
  464. package/esm/Sidebar/Sidebar.js +4 -0
  465. package/esm/Sidenav/Sidenav.d.ts +4 -0
  466. package/esm/Sidenav/Sidenav.js +5 -0
  467. package/esm/Sidenav/SidenavBody.d.ts +5 -0
  468. package/esm/Sidenav/SidenavBody.js +5 -0
  469. package/esm/Sidenav/SidenavHeader.d.ts +5 -0
  470. package/esm/Sidenav/SidenavHeader.js +5 -0
  471. package/esm/Slider/Slider.d.ts +5 -0
  472. package/esm/Slider/Slider.js +6 -0
  473. package/esm/Stack/Stack.d.ts +6 -0
  474. package/esm/Stack/Stack.js +6 -0
  475. package/esm/Stack/StackItem.d.ts +5 -0
  476. package/esm/Stack/StackItem.js +5 -0
  477. package/esm/Steps/StepItem.d.ts +5 -0
  478. package/esm/Steps/StepItem.js +5 -0
  479. package/esm/Steps/Steps.d.ts +5 -0
  480. package/esm/Steps/Steps.js +5 -0
  481. package/esm/Table/Table.d.ts +19 -2
  482. package/esm/Table/Table.js +23 -4
  483. package/esm/Tag/Tag.d.ts +6 -0
  484. package/esm/Tag/Tag.js +6 -0
  485. package/esm/TagGroup/TagGroup.d.ts +5 -0
  486. package/esm/TagGroup/TagGroup.js +5 -0
  487. package/esm/TagInput/index.d.ts +5 -0
  488. package/esm/TagInput/index.js +5 -0
  489. package/esm/TagPicker/index.d.ts +2 -1
  490. package/esm/TagPicker/index.js +2 -1
  491. package/esm/Timeline/Timeline.d.ts +5 -0
  492. package/esm/Timeline/Timeline.js +5 -0
  493. package/esm/Timeline/TimelineItem.d.ts +5 -0
  494. package/esm/Timeline/TimelineItem.js +5 -0
  495. package/esm/Toggle/Toggle.d.ts +5 -0
  496. package/esm/Toggle/Toggle.js +5 -0
  497. package/esm/Tooltip/Tooltip.d.ts +5 -0
  498. package/esm/Tooltip/Tooltip.js +5 -0
  499. package/esm/Tree/Tree.d.ts +5 -0
  500. package/esm/Tree/Tree.js +5 -0
  501. package/esm/TreePicker/TreePicker.d.ts +5 -0
  502. package/esm/TreePicker/TreePicker.js +6 -0
  503. package/esm/Uploader/Uploader.d.ts +5 -0
  504. package/esm/Uploader/Uploader.js +6 -0
  505. package/esm/Whisper/Whisper.d.ts +6 -0
  506. package/esm/Whisper/Whisper.js +6 -0
  507. package/esm/Windowing/AutoSizer.d.ts +5 -0
  508. package/esm/Windowing/AutoSizer.js +5 -0
  509. package/esm/Windowing/List.d.ts +6 -1
  510. package/esm/Windowing/List.js +5 -0
  511. package/esm/index.d.ts +3 -0
  512. package/esm/index.js +3 -1
  513. package/esm/toaster/toaster.d.ts +9 -7
  514. package/esm/toaster/useToaster.d.ts +19 -1
  515. package/esm/toaster/useToaster.js +19 -1
  516. package/esm/useMediaQuery/index.d.ts +2 -0
  517. package/esm/useMediaQuery/index.js +3 -0
  518. package/esm/useMediaQuery/useMediaQuery.d.ts +23 -0
  519. package/esm/useMediaQuery/useMediaQuery.js +113 -0
  520. package/esm/utils/BrowserDetection.d.ts +1 -0
  521. package/esm/utils/BrowserDetection.js +3 -0
  522. package/esm/utils/dateUtils.d.ts +6 -0
  523. package/esm/utils/dateUtils.js +6 -0
  524. package/esm/utils/index.d.ts +1 -0
  525. package/esm/utils/index.js +1 -0
  526. package/esm/utils/safeSetSelection.d.ts +2 -0
  527. package/esm/utils/safeSetSelection.js +16 -0
  528. package/esm/utils/treeUtils.d.ts +2 -2
  529. package/package.json +1 -1
  530. package/useMediaQuery/package.json +7 -0
@@ -8,6 +8,12 @@ import ToastContainer, { toastPlacements } from '../toaster/ToastContainer';
8
8
  import { usePortal } from '../utils';
9
9
  var CustomContext = /*#__PURE__*/React.createContext({});
10
10
  var themes = ['light', 'dark', 'high-contrast'];
11
+
12
+ /**
13
+ * CustomProvider is used to provide global configuration, such as language, theme, etc.
14
+ *
15
+ * @see https://rsuitejs.com/components/custom-provider
16
+ */
11
17
  var CustomProvider = function CustomProvider(props) {
12
18
  var children = props.children,
13
19
  _props$classPrefix = props.classPrefix,
@@ -1,6 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import * as helpers from 'dom-lib';
3
3
  export * from 'dom-lib';
4
+ /**
5
+ * a wrapper of dom-lib with some custom methods.
6
+ * @see https://rsuitejs.com/components/dom-helper/
7
+ */
4
8
  declare const DOMHelper: {
5
9
  isElement: (value: any) => value is HTMLElement;
6
10
  on: typeof helpers.on;
@@ -3,6 +3,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import * as helpers from 'dom-lib';
4
4
  import isElement from './isElement';
5
5
  export * from 'dom-lib';
6
+
7
+ /**
8
+ * a wrapper of dom-lib with some custom methods.
9
+ * @see https://rsuitejs.com/components/dom-helper/
10
+ */
6
11
  var DOMHelper = _extends({}, helpers, {
7
12
  isElement: isElement
8
13
  });
@@ -0,0 +1,180 @@
1
+ /// <reference types="react" />
2
+ import { type Locale } from 'date-fns';
3
+ export declare const patternMap: {
4
+ y: string;
5
+ M: string;
6
+ d: string;
7
+ H: string;
8
+ h: string;
9
+ m: string;
10
+ s: string;
11
+ a: string;
12
+ };
13
+ export declare class DateField extends Object {
14
+ format: string;
15
+ patternArray: {
16
+ pattern: string;
17
+ key: string;
18
+ }[];
19
+ year: number | null;
20
+ month: number | null;
21
+ day: number | null;
22
+ hour: number | null;
23
+ minute: number | null;
24
+ second: number | null;
25
+ meridian: 'AM' | 'PM' | null;
26
+ constructor(format: string, value?: Date | null);
27
+ }
28
+ export declare const useDateField: (format: string, localize: Locale['localize'], date?: Date | null) => {
29
+ dateField: {
30
+ year: any;
31
+ format: string;
32
+ patternArray: {
33
+ pattern: string;
34
+ key: string;
35
+ }[];
36
+ month: number | null;
37
+ day: number | null;
38
+ hour: number | null;
39
+ minute: number | null;
40
+ second: number | null;
41
+ meridian: 'AM' | 'PM' | null;
42
+ constructor: Function;
43
+ toString(): string;
44
+ toLocaleString(): string;
45
+ valueOf(): Object;
46
+ hasOwnProperty(v: PropertyKey): boolean;
47
+ isPrototypeOf(v: Object): boolean;
48
+ propertyIsEnumerable(v: PropertyKey): boolean;
49
+ should: Chai.Assertion;
50
+ } | {
51
+ month: any;
52
+ format: string;
53
+ patternArray: {
54
+ pattern: string;
55
+ key: string;
56
+ }[];
57
+ year: number | null;
58
+ day: number | null;
59
+ hour: number | null;
60
+ minute: number | null;
61
+ second: number | null;
62
+ meridian: 'AM' | 'PM' | null;
63
+ constructor: Function;
64
+ toString(): string;
65
+ toLocaleString(): string;
66
+ valueOf(): Object;
67
+ hasOwnProperty(v: PropertyKey): boolean;
68
+ isPrototypeOf(v: Object): boolean;
69
+ propertyIsEnumerable(v: PropertyKey): boolean;
70
+ should: Chai.Assertion;
71
+ } | {
72
+ day: any;
73
+ format: string;
74
+ patternArray: {
75
+ pattern: string;
76
+ key: string;
77
+ }[];
78
+ year: number | null;
79
+ month: number | null;
80
+ hour: number | null;
81
+ minute: number | null;
82
+ second: number | null;
83
+ meridian: 'AM' | 'PM' | null;
84
+ constructor: Function;
85
+ toString(): string;
86
+ toLocaleString(): string;
87
+ valueOf(): Object;
88
+ hasOwnProperty(v: PropertyKey): boolean;
89
+ isPrototypeOf(v: Object): boolean;
90
+ propertyIsEnumerable(v: PropertyKey): boolean;
91
+ should: Chai.Assertion;
92
+ } | {
93
+ hour: any;
94
+ format: string;
95
+ patternArray: {
96
+ pattern: string;
97
+ key: string;
98
+ }[];
99
+ year: number | null;
100
+ month: number | null;
101
+ day: number | null;
102
+ minute: number | null;
103
+ second: number | null;
104
+ meridian: 'AM' | 'PM' | null;
105
+ constructor: Function;
106
+ toString(): string;
107
+ toLocaleString(): string;
108
+ valueOf(): Object;
109
+ hasOwnProperty(v: PropertyKey): boolean;
110
+ isPrototypeOf(v: Object): boolean;
111
+ propertyIsEnumerable(v: PropertyKey): boolean;
112
+ should: Chai.Assertion;
113
+ } | {
114
+ minute: any;
115
+ format: string;
116
+ patternArray: {
117
+ pattern: string;
118
+ key: string;
119
+ }[];
120
+ year: number | null;
121
+ month: number | null;
122
+ day: number | null;
123
+ hour: number | null;
124
+ second: number | null;
125
+ meridian: 'AM' | 'PM' | null;
126
+ constructor: Function;
127
+ toString(): string;
128
+ toLocaleString(): string;
129
+ valueOf(): Object;
130
+ hasOwnProperty(v: PropertyKey): boolean;
131
+ isPrototypeOf(v: Object): boolean;
132
+ propertyIsEnumerable(v: PropertyKey): boolean;
133
+ should: Chai.Assertion;
134
+ } | {
135
+ second: any;
136
+ format: string;
137
+ patternArray: {
138
+ pattern: string;
139
+ key: string;
140
+ }[];
141
+ year: number | null;
142
+ month: number | null;
143
+ day: number | null;
144
+ hour: number | null;
145
+ minute: number | null;
146
+ meridian: 'AM' | 'PM' | null;
147
+ constructor: Function;
148
+ toString(): string;
149
+ toLocaleString(): string;
150
+ valueOf(): Object;
151
+ hasOwnProperty(v: PropertyKey): boolean;
152
+ isPrototypeOf(v: Object): boolean;
153
+ propertyIsEnumerable(v: PropertyKey): boolean;
154
+ should: Chai.Assertion;
155
+ } | {
156
+ meridian: any;
157
+ format: string;
158
+ patternArray: {
159
+ pattern: string;
160
+ key: string;
161
+ }[];
162
+ year: number | null;
163
+ month: number | null;
164
+ day: number | null;
165
+ hour: number | null;
166
+ minute: number | null;
167
+ second: number | null;
168
+ constructor: Function;
169
+ toString(): string;
170
+ toLocaleString(): string;
171
+ valueOf(): Object;
172
+ hasOwnProperty(v: PropertyKey): boolean;
173
+ isPrototypeOf(v: Object): boolean;
174
+ propertyIsEnumerable(v: PropertyKey): boolean;
175
+ should: Chai.Assertion;
176
+ };
177
+ dispatch: import("react").Dispatch<any>;
178
+ toDate: (type: string, value: number | null) => Date;
179
+ toDateString: () => string;
180
+ };
@@ -0,0 +1,144 @@
1
+ 'use client';
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
4
+ import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
5
+ import { useReducer } from 'react';
6
+ import { modifyDate } from './utils';
7
+ export var patternMap = {
8
+ y: 'year',
9
+ M: 'month',
10
+ d: 'day',
11
+ H: 'hour',
12
+ h: 'hour',
13
+ m: 'minute',
14
+ s: 'second',
15
+ a: 'meridian'
16
+ };
17
+ export var DateField = /*#__PURE__*/function (_Object) {
18
+ _inheritsLoose(DateField, _Object);
19
+ function DateField(format, value) {
20
+ var _this;
21
+ _this = _Object.call(this) || this;
22
+ _this.format = void 0;
23
+ _this.patternArray = [];
24
+ _this.year = null;
25
+ _this.month = null;
26
+ _this.day = null;
27
+ _this.hour = null;
28
+ _this.minute = null;
29
+ _this.second = null;
30
+ _this.meridian = null;
31
+ _this.format = format;
32
+ var formatArray = format.match(new RegExp('([y|d|M|H|h|m|s|a])+', 'ig')) || [];
33
+ _this.patternArray = formatArray.map(function (pattern) {
34
+ return {
35
+ pattern: pattern,
36
+ key: patternMap[pattern[0]]
37
+ };
38
+ });
39
+ if (value) {
40
+ _this.year = value.getFullYear();
41
+ _this.month = value.getMonth() + 1;
42
+ _this.day = value.getDate();
43
+ _this.hour = value.getHours();
44
+ _this.minute = value.getMinutes();
45
+ _this.second = value.getSeconds();
46
+ _this.meridian = value.getHours() > 12 ? 'PM' : 'AM';
47
+ }
48
+ return _this;
49
+ }
50
+ return DateField;
51
+ }( /*#__PURE__*/_wrapNativeSuper(Object));
52
+
53
+ /**
54
+ * Pad a number with zeros to the left.
55
+ */
56
+ function padNumber(number, length) {
57
+ var numberString = String(number);
58
+ if (numberString.length >= length) {
59
+ return numberString;
60
+ }
61
+ var paddingCount = length - numberString.length;
62
+ for (var i = 0; i < paddingCount; i++) {
63
+ numberString = '0' + numberString;
64
+ }
65
+ return numberString;
66
+ }
67
+ export var useDateField = function useDateField(format, localize, date) {
68
+ var _useReducer = useReducer(function (state, action) {
69
+ switch (action.type) {
70
+ case 'setYear':
71
+ return _extends({}, state, {
72
+ year: action.value
73
+ });
74
+ case 'setMonth':
75
+ return _extends({}, state, {
76
+ month: action.value
77
+ });
78
+ case 'setDay':
79
+ return _extends({}, state, {
80
+ day: action.value
81
+ });
82
+ case 'setHour':
83
+ return _extends({}, state, {
84
+ hour: action.value
85
+ });
86
+ case 'setMinute':
87
+ return _extends({}, state, {
88
+ minute: action.value
89
+ });
90
+ case 'setSecond':
91
+ return _extends({}, state, {
92
+ second: action.value
93
+ });
94
+ case 'setMeridian':
95
+ return _extends({}, state, {
96
+ meridian: action.value
97
+ });
98
+ default:
99
+ return state;
100
+ }
101
+ }, new DateField(format, date)),
102
+ dateField = _useReducer[0],
103
+ dispatch = _useReducer[1];
104
+ var toDateString = function toDateString() {
105
+ var str = format;
106
+ dateField.patternArray.forEach(function (item) {
107
+ var key = item.key,
108
+ pattern = item.pattern;
109
+ var value = dateField[key];
110
+ if (value !== null) {
111
+ if (pattern === 'MMM' && typeof value === 'number') {
112
+ value = localize === null || localize === void 0 ? void 0 : localize.month(value - 1, {
113
+ width: 'abbreviated'
114
+ });
115
+ } else if (pattern === 'MMMM' && typeof value === 'number') {
116
+ value = localize === null || localize === void 0 ? void 0 : localize.month(value - 1, {
117
+ width: 'wide'
118
+ });
119
+ } else if (pattern === 'aa' && typeof value === 'number') {
120
+ value = value === 0 ? 'AM' : 'PM';
121
+ } else if (pattern === 'hh' && typeof value === 'number') {
122
+ value = value === 0 ? 12 : value > 12 ? value - 12 : value;
123
+ }
124
+ if (typeof value === 'number') {
125
+ value = padNumber(value, pattern.length);
126
+ }
127
+ str = str.replace(pattern, value);
128
+ }
129
+ });
130
+ return str;
131
+ };
132
+ var toDate = function toDate(type, value) {
133
+ if (value === null) {
134
+ return new Date('');
135
+ }
136
+ return modifyDate(new Date(dateField.year, dateField.month ? dateField.month - 1 : 0, dateField.day, dateField.hour, dateField.minute, dateField.second), type, value);
137
+ };
138
+ return {
139
+ dateField: dateField,
140
+ dispatch: dispatch,
141
+ toDate: toDate,
142
+ toDateString: toDateString
143
+ };
144
+ };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { InputProps } from '../Input';
3
+ import { FormControlBaseProps } from '../@types/common';
4
+ export interface DateInputProps extends Omit<InputProps, 'value' | 'onChange' | 'defaultValue'>, FormControlBaseProps<Date | null> {
5
+ /**
6
+ * Format of the date when rendered in the input.
7
+ * Format of the string is based on Unicode Technical Standard: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
8
+ * @default 'yyyy-MM-dd'
9
+ **/
10
+ format?: string;
11
+ }
12
+ /**
13
+ * The DateInput component lets users select a date with the keyboard.
14
+ * @version 5.58.0
15
+ * @see https://rsuitejs.com/components/date-input/
16
+ */
17
+ declare const DateInput: React.ForwardRefExoticComponent<DateInputProps & React.RefAttributes<unknown>>;
18
+ export default DateInput;
@@ -0,0 +1,215 @@
1
+ 'use client';
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
+ import React, { useState, useCallback, useRef, useMemo } from 'react';
5
+ import Input from '../Input';
6
+ import { mergeRefs, useCustom, useControlled, safeSetSelection } from '../utils';
7
+ import { getInputSelectedState, validateDateTime, getPatternGroups } from './utils';
8
+ import useDateInputState from './useDateInputState';
9
+ var isTestEnvironment = process.env.RUN_ENV === 'test';
10
+ /**
11
+ * The DateInput component lets users select a date with the keyboard.
12
+ * @version 5.58.0
13
+ * @see https://rsuitejs.com/components/date-input/
14
+ */
15
+ var DateInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
16
+ var _props$format = props.format,
17
+ formatStr = _props$format === void 0 ? 'yyyy-MM-dd' : _props$format,
18
+ valueProp = props.value,
19
+ defaultValue = props.defaultValue,
20
+ onChange = props.onChange,
21
+ onKeyDown = props.onKeyDown,
22
+ rest = _objectWithoutPropertiesLoose(props, ["format", "value", "defaultValue", "onChange", "onKeyDown"]);
23
+ var inputRef = useRef();
24
+ var _useState = useState({
25
+ selectedPattern: 'y',
26
+ selectionStart: 0,
27
+ selectionEnd: 0
28
+ }),
29
+ selectedState = _useState[0],
30
+ setSelectedState = _useState[1];
31
+ var _useCustom = useCustom('Calendar'),
32
+ locale = _useCustom.locale;
33
+ var localize = locale.dateLocale.localize;
34
+ var _useControlled = useControlled(valueProp, defaultValue),
35
+ value = _useControlled[0],
36
+ setValue = _useControlled[1],
37
+ isControlled = _useControlled[2];
38
+ var _useDateInputState = useDateInputState({
39
+ formatStr: formatStr,
40
+ localize: localize,
41
+ date: value,
42
+ isControlledDate: isControlled
43
+ }),
44
+ dateField = _useDateInputState.dateField,
45
+ setDateOffset = _useDateInputState.setDateOffset,
46
+ setDateField = _useDateInputState.setDateField,
47
+ getDateField = _useDateInputState.getDateField,
48
+ toDateString = _useDateInputState.toDateString;
49
+ var dateString = toDateString();
50
+ var keyPressOptions = useMemo(function () {
51
+ return {
52
+ formatStr: formatStr,
53
+ localize: localize,
54
+ selectedMonth: dateField.month,
55
+ dateString: dateString
56
+ };
57
+ }, [dateField, dateString, formatStr, localize]);
58
+ var setSelectionRange = useCallback(function (selectionStart, selectionEnd) {
59
+ if (selectionStart === void 0) {
60
+ selectionStart = selectedState.selectionStart;
61
+ }
62
+ if (selectionEnd === void 0) {
63
+ selectionEnd = selectedState.selectionEnd;
64
+ }
65
+ var input = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current;
66
+ if (isTestEnvironment) {
67
+ safeSetSelection(input, selectionStart, selectionEnd);
68
+ return;
69
+ }
70
+ requestAnimationFrame(function () {
71
+ safeSetSelection(input, selectionStart, selectionEnd);
72
+ });
73
+ }, [selectedState]);
74
+ var handleChange = useCallback(function (value, event) {
75
+ setValue(value);
76
+ onChange === null || onChange === void 0 ? void 0 : onChange(value, event);
77
+ }, [onChange, setValue]);
78
+ var handleChangeField = useCallback(function (event, nextDirection) {
79
+ var input = event.target;
80
+ var direction = nextDirection || (event.key === 'ArrowRight' ? 'right' : 'left');
81
+ var state = getInputSelectedState(_extends({}, keyPressOptions, {
82
+ input: input,
83
+ direction: direction
84
+ }));
85
+ setSelectionRange(state.selectionStart, state.selectionEnd);
86
+ setSelectedState(state);
87
+ }, [keyPressOptions, setSelectionRange]);
88
+ var handleChangeFieldValue = useCallback(function (event) {
89
+ var key = event.key;
90
+ var input = event.target;
91
+ var offset = key === 'ArrowUp' ? 1 : -1;
92
+ var state = getInputSelectedState(_extends({}, keyPressOptions, {
93
+ input: input,
94
+ valueOffset: offset
95
+ }));
96
+ setSelectedState(state);
97
+ setDateOffset(state.selectedPattern, offset, function (date) {
98
+ return handleChange(date, event);
99
+ });
100
+ setSelectionRange(state.selectionStart, state.selectionEnd);
101
+ }, [handleChange, keyPressOptions, setDateOffset, setSelectionRange]);
102
+ var isFieldFullValue = useCallback(function (value, pattern) {
103
+ var patternGroup = getPatternGroups(formatStr, pattern);
104
+ if (value.toString().length === patternGroup.length) {
105
+ return true;
106
+ }
107
+ switch (pattern) {
108
+ case 'M':
109
+ return parseInt(value + "0") > 12;
110
+ case 'd':
111
+ return parseInt(value + "0") > 31;
112
+ case 'H':
113
+ return parseInt(value + "0") > 23;
114
+ case 'h':
115
+ return parseInt(value + "0") > 12;
116
+ case 'm':
117
+ case 's':
118
+ return parseInt(value + "0") > 59;
119
+ default:
120
+ return false;
121
+ }
122
+ }, [formatStr]);
123
+ var handleChangeFieldValueWithNumericKeys = useCallback(function (event) {
124
+ var key = event.key;
125
+ var input = event.target;
126
+ var pattern = selectedState.selectedPattern;
127
+ if (!pattern) {
128
+ return;
129
+ }
130
+ var field = getDateField(pattern);
131
+ var value = parseInt(key, 10);
132
+ var padValue = parseInt("" + (field.value || '') + key, 10);
133
+ var newValue = value;
134
+
135
+ // Check if the value entered by the user is a valid date
136
+ if (validateDateTime(field.name, padValue)) {
137
+ newValue = padValue;
138
+ }
139
+ if (pattern === 'M') {
140
+ // Month cannot be less than 1.
141
+ newValue = Math.max(1, newValue);
142
+ }
143
+ setDateField(pattern, newValue, function (date) {
144
+ return handleChange(date, event);
145
+ });
146
+
147
+ // The currently selected month will be retained as a parameter of getInputSelectedState,
148
+ // but if the user enters a month, the month value will be replaced with the value entered by the user.
149
+ var selectedMonth = pattern === 'M' ? newValue : dateField.month;
150
+ var nextState = getInputSelectedState(_extends({}, keyPressOptions, {
151
+ input: input,
152
+ selectedMonth: selectedMonth
153
+ }));
154
+ setSelectedState(nextState);
155
+ setSelectionRange(nextState.selectionStart, nextState.selectionEnd);
156
+
157
+ // If the field is full value, move the cursor to the next field
158
+ if (isFieldFullValue(newValue, pattern) && input.selectionEnd !== input.value.length) {
159
+ handleChangeField(event, 'right');
160
+ }
161
+ }, [dateField, getDateField, handleChange, handleChangeField, isFieldFullValue, keyPressOptions, selectedState.selectedPattern, setDateField, setSelectionRange]);
162
+ var handleRemoveFieldValue = useCallback(function (event) {
163
+ if (selectedState.selectedPattern) {
164
+ setDateField(selectedState.selectedPattern, null, function (date) {
165
+ return handleChange(date, event);
166
+ });
167
+ setSelectionRange();
168
+ }
169
+ }, [handleChange, selectedState, setDateField, setSelectionRange]);
170
+ var handleKeyDown = function handleKeyDown(event) {
171
+ var _key$match;
172
+ var key = event.key;
173
+ switch (key) {
174
+ case 'ArrowRight':
175
+ case 'ArrowLeft':
176
+ handleChangeField(event);
177
+ event.preventDefault();
178
+ break;
179
+ case 'ArrowUp':
180
+ case 'ArrowDown':
181
+ handleChangeFieldValue(event);
182
+ event.preventDefault();
183
+ break;
184
+ case 'Backspace':
185
+ handleRemoveFieldValue(event);
186
+ event.preventDefault();
187
+ break;
188
+ case (_key$match = key.match(/\d/)) === null || _key$match === void 0 ? void 0 : _key$match.input:
189
+ handleChangeFieldValueWithNumericKeys(event);
190
+ event.preventDefault();
191
+ break;
192
+ }
193
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
194
+ };
195
+ var handleClick = useCallback(function (event) {
196
+ var input = event.target;
197
+ var state = getInputSelectedState(_extends({}, keyPressOptions, {
198
+ input: input
199
+ }));
200
+ setSelectedState(state);
201
+ setSelectionRange(state.selectionStart, state.selectionEnd);
202
+ }, [keyPressOptions, setSelectionRange]);
203
+ return /*#__PURE__*/React.createElement(Input, _extends({
204
+ inputMode: "text",
205
+ autoComplete: "off",
206
+ autoCorrect: "off",
207
+ spellCheck: false,
208
+ ref: mergeRefs(inputRef, ref),
209
+ onKeyDown: handleKeyDown,
210
+ onClick: handleClick,
211
+ value: dateString
212
+ }, rest));
213
+ });
214
+ DateInput.displayName = 'DateInput';
215
+ export default DateInput;
@@ -0,0 +1,3 @@
1
+ import DateInput from './DateInput';
2
+ export type { DateInputProps } from './DateInput';
3
+ export default DateInput;
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ import DateInput from './DateInput';
3
+ export default DateInput;