rsuite 5.0.0 → 5.1.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 (365) hide show
  1. package/CHANGELOG.md +67 -6
  2. package/Grid/styles/index.less +1 -2
  3. package/IconButton/styles/index.less +1 -1
  4. package/MaskedInput/package.json +7 -0
  5. package/MultiCascader/styles/index.less +3 -0
  6. package/Navbar/styles/index.less +8 -0
  7. package/Picker/styles/index.less +1 -1
  8. package/Picker/styles/mixin.less +1 -1
  9. package/README.md +16 -10
  10. package/Sidenav/styles/index.less +13 -16
  11. package/Toggle/styles/index.less +20 -0
  12. package/Toggle/styles/mixin.less +12 -0
  13. package/Uploader/styles/index.less +10 -1
  14. package/cjs/@types/common.d.ts +0 -1
  15. package/cjs/Animation/Collapse.js +8 -8
  16. package/cjs/AutoComplete/AutoComplete.js +10 -14
  17. package/cjs/Badge/Badge.js +6 -10
  18. package/cjs/Breadcrumb/Breadcrumb.js +8 -12
  19. package/cjs/Breadcrumb/BreadcrumbItem.js +4 -8
  20. package/cjs/Button/Button.js +6 -10
  21. package/cjs/ButtonGroup/ButtonGroup.js +6 -10
  22. package/cjs/Calendar/Calendar.js +4 -8
  23. package/cjs/Calendar/CalendarPanel.js +6 -10
  24. package/cjs/Calendar/Header.js +4 -8
  25. package/cjs/Calendar/MonthDropdown.js +10 -14
  26. package/cjs/Calendar/MonthDropdownItem.js +6 -10
  27. package/cjs/Calendar/Table.js +6 -10
  28. package/cjs/Calendar/TableHeaderRow.js +4 -7
  29. package/cjs/Calendar/TableRow.js +7 -11
  30. package/cjs/Calendar/TimeDropdown.js +4 -8
  31. package/cjs/Calendar/View.js +4 -8
  32. package/cjs/Carousel/Carousel.js +10 -14
  33. package/cjs/Cascader/Cascader.js +29 -26
  34. package/cjs/Cascader/DropdownMenu.js +19 -21
  35. package/cjs/CheckPicker/CheckPicker.js +33 -29
  36. package/cjs/CheckTreePicker/CheckTreeNode.js +4 -6
  37. package/cjs/CheckTreePicker/CheckTreePicker.js +47 -35
  38. package/cjs/Checkbox/Checkbox.js +8 -13
  39. package/cjs/CheckboxGroup/CheckboxGroup.d.ts +1 -12
  40. package/cjs/CheckboxGroup/CheckboxGroup.js +7 -13
  41. package/cjs/CheckboxGroup/CheckboxGroupContext.d.ts +13 -0
  42. package/cjs/CheckboxGroup/CheckboxGroupContext.js +12 -0
  43. package/cjs/CheckboxGroup/index.d.ts +4 -3
  44. package/cjs/CheckboxGroup/index.js +6 -4
  45. package/cjs/Col/Col.js +3 -2
  46. package/cjs/Container/Container.js +4 -7
  47. package/cjs/DOMHelper/index.d.ts +1 -1
  48. package/cjs/DatePicker/DatePicker.js +27 -22
  49. package/cjs/DatePicker/Toolbar.js +4 -8
  50. package/cjs/DateRangePicker/Calendar.js +12 -14
  51. package/cjs/DateRangePicker/DateRangePicker.js +40 -33
  52. package/cjs/Divider/Divider.js +4 -8
  53. package/cjs/Drawer/Drawer.js +8 -10
  54. package/cjs/Dropdown/Dropdown.js +8 -12
  55. package/cjs/Dropdown/DropdownItem.js +25 -22
  56. package/cjs/Dropdown/DropdownMenu.js +2 -6
  57. package/cjs/Dropdown/DropdownToggle.js +4 -8
  58. package/cjs/FlexboxGrid/FlexboxGrid.js +8 -12
  59. package/cjs/FlexboxGrid/FlexboxGridItem.js +8 -12
  60. package/cjs/Form/Form.js +12 -16
  61. package/cjs/FormControl/FormControl.js +6 -2
  62. package/cjs/IconButton/IconButton.js +4 -8
  63. package/cjs/Input/Input.js +6 -10
  64. package/cjs/InputNumber/InputNumber.js +14 -18
  65. package/cjs/InputPicker/InputAutosize.js +2 -4
  66. package/cjs/InputPicker/InputPicker.js +32 -30
  67. package/cjs/List/List.js +12 -16
  68. package/cjs/List/ListItem.js +6 -10
  69. package/cjs/Loader/Loader.js +6 -10
  70. package/cjs/MaskedInput/MaskedInput.d.ts +43 -0
  71. package/cjs/MaskedInput/MaskedInput.js +80 -0
  72. package/cjs/MaskedInput/adjustCaretPosition.d.ts +11 -0
  73. package/cjs/MaskedInput/adjustCaretPosition.js +218 -0
  74. package/cjs/MaskedInput/conformToMask.d.ts +8 -0
  75. package/cjs/MaskedInput/conformToMask.js +247 -0
  76. package/cjs/MaskedInput/createTextMaskInputElement.d.ts +7 -0
  77. package/cjs/MaskedInput/createTextMaskInputElement.js +226 -0
  78. package/cjs/MaskedInput/index.d.ts +3 -0
  79. package/cjs/MaskedInput/index.js +11 -0
  80. package/cjs/MaskedInput/types.d.ts +10 -0
  81. package/cjs/{@types/icons.js → MaskedInput/types.js} +0 -0
  82. package/cjs/MaskedInput/utilities.d.ts +7 -0
  83. package/cjs/MaskedInput/utilities.js +47 -0
  84. package/cjs/Menu/Menu.d.ts +0 -1
  85. package/cjs/Menu/Menu.js +3 -5
  86. package/cjs/Message/Message.js +8 -12
  87. package/cjs/Modal/Modal.d.ts +1 -10
  88. package/cjs/Modal/Modal.js +35 -27
  89. package/cjs/Modal/ModalBody.js +6 -10
  90. package/cjs/Modal/ModalContext.d.ts +12 -0
  91. package/cjs/Modal/ModalContext.js +12 -0
  92. package/cjs/Modal/ModalDialog.js +8 -8
  93. package/cjs/Modal/ModalHeader.js +8 -12
  94. package/cjs/Modal/ModalTitle.d.ts +3 -2
  95. package/cjs/Modal/ModalTitle.js +43 -4
  96. package/cjs/MultiCascader/DropdownMenu.js +21 -23
  97. package/cjs/MultiCascader/MultiCascader.js +35 -32
  98. package/cjs/Nav/Nav.js +6 -10
  99. package/cjs/Navbar/Navbar.js +6 -9
  100. package/cjs/Notification/Notification.js +6 -10
  101. package/cjs/Overlay/Modal.js +11 -18
  102. package/cjs/Overlay/Overlay.js +2 -5
  103. package/cjs/Overlay/OverlayTrigger.js +9 -9
  104. package/cjs/Overlay/Position.js +4 -8
  105. package/cjs/Overlay/positionUtils.js +1 -1
  106. package/cjs/Pagination/Pagination.js +10 -13
  107. package/cjs/Pagination/PaginationButton.js +4 -8
  108. package/cjs/Pagination/PaginationGroup.js +11 -12
  109. package/cjs/Panel/Panel.js +6 -10
  110. package/cjs/PanelGroup/PanelGroup.js +4 -8
  111. package/cjs/Picker/DropdownMenu.js +2 -3
  112. package/cjs/Picker/DropdownMenuGroup.js +4 -8
  113. package/cjs/Picker/DropdownMenuItem.js +4 -8
  114. package/cjs/Picker/PickerToggle.js +15 -14
  115. package/cjs/Picker/propTypes.d.ts +2 -16
  116. package/cjs/Picker/propTypes.js +4 -17
  117. package/cjs/Picker/utils.js +14 -9
  118. package/cjs/Placeholder/PlaceholderGraph.js +6 -10
  119. package/cjs/Placeholder/PlaceholderGrid.js +12 -16
  120. package/cjs/Placeholder/PlaceholderParagraph.js +10 -14
  121. package/cjs/Popover/Popover.js +4 -8
  122. package/cjs/Progress/ProgressCircle.js +18 -22
  123. package/cjs/Progress/ProgressLine.js +8 -12
  124. package/cjs/Radio/Radio.js +6 -11
  125. package/cjs/RadioGroup/RadioGroup.js +6 -9
  126. package/cjs/RangeSlider/RangeSlider.js +17 -20
  127. package/cjs/Rate/Character.js +4 -7
  128. package/cjs/Rate/Rate.js +14 -18
  129. package/cjs/Ripple/Ripple.js +4 -8
  130. package/cjs/SelectPicker/SelectPicker.js +31 -28
  131. package/cjs/Sidebar/Sidebar.js +6 -10
  132. package/cjs/Sidenav/Sidenav.js +8 -11
  133. package/cjs/Sidenav/SidenavDropdown.d.ts +6 -1
  134. package/cjs/Sidenav/SidenavDropdown.js +19 -19
  135. package/cjs/Sidenav/SidenavDropdownCollapse.js +2 -6
  136. package/cjs/Sidenav/SidenavDropdownItem.js +4 -8
  137. package/cjs/Sidenav/SidenavDropdownMenu.js +4 -8
  138. package/cjs/Sidenav/SidenavToggle.js +4 -8
  139. package/cjs/Slider/Graduated.js +4 -8
  140. package/cjs/Slider/Handle.d.ts +2 -0
  141. package/cjs/Slider/Handle.js +23 -12
  142. package/cjs/Slider/Input.d.ts +3 -0
  143. package/cjs/Slider/Input.js +35 -0
  144. package/cjs/Slider/Mark.js +4 -8
  145. package/cjs/Slider/ProgressBar.js +4 -8
  146. package/cjs/Slider/Slider.d.ts +0 -3
  147. package/cjs/Slider/Slider.js +14 -22
  148. package/cjs/Steps/StepItem.js +4 -7
  149. package/cjs/Steps/Steps.js +8 -12
  150. package/cjs/Table/Table.d.ts +7 -7
  151. package/cjs/Table/Table.js +5 -5
  152. package/cjs/TagInput/index.js +4 -6
  153. package/cjs/TagPicker/index.d.ts +1 -1
  154. package/cjs/TagPicker/index.js +4 -6
  155. package/cjs/Timeline/Timeline.js +6 -11
  156. package/cjs/Timeline/TimelineItem.js +4 -8
  157. package/cjs/Toggle/Toggle.d.ts +2 -0
  158. package/cjs/Toggle/Toggle.js +27 -13
  159. package/cjs/Tooltip/Tooltip.js +4 -8
  160. package/cjs/Tree/Tree.d.ts +6 -0
  161. package/cjs/TreePicker/TreeNode.js +4 -6
  162. package/cjs/TreePicker/TreePicker.js +38 -29
  163. package/cjs/Uploader/UploadFileItem.d.ts +1 -0
  164. package/cjs/Uploader/UploadFileItem.js +42 -33
  165. package/cjs/Uploader/UploadTrigger.js +4 -8
  166. package/cjs/Uploader/Uploader.d.ts +2 -0
  167. package/cjs/Uploader/Uploader.js +28 -29
  168. package/cjs/index.d.ts +2 -0
  169. package/cjs/index.js +5 -1
  170. package/cjs/locales/fa_IR.d.ts +105 -0
  171. package/cjs/locales/fa_IR.js +84 -0
  172. package/cjs/locales/index.d.ts +1 -0
  173. package/cjs/locales/index.js +6 -2
  174. package/cjs/toaster/ToastContainer.js +6 -10
  175. package/cjs/utils/createComponent.d.ts +1 -2
  176. package/cjs/utils/createComponent.js +10 -13
  177. package/cjs/utils/previewFile.d.ts +1 -0
  178. package/cjs/utils/previewFile.js +11 -0
  179. package/cjs/utils/useUniqueId.d.ts +3 -1
  180. package/cjs/utils/useUniqueId.js +4 -2
  181. package/dist/rsuite-rtl.css +115 -44
  182. package/dist/rsuite-rtl.min.css +1 -1
  183. package/dist/rsuite-rtl.min.css.map +1 -1
  184. package/dist/rsuite.css +115 -44
  185. package/dist/rsuite.js +233 -144
  186. package/dist/rsuite.js.map +1 -1
  187. package/dist/rsuite.min.css +1 -1
  188. package/dist/rsuite.min.css.map +1 -1
  189. package/dist/rsuite.min.js +1 -1
  190. package/dist/rsuite.min.js.map +1 -1
  191. package/esm/@types/common.d.ts +0 -1
  192. package/esm/Animation/Collapse.js +8 -8
  193. package/esm/AutoComplete/AutoComplete.js +11 -14
  194. package/esm/Badge/Badge.js +6 -9
  195. package/esm/Breadcrumb/Breadcrumb.js +8 -11
  196. package/esm/Breadcrumb/BreadcrumbItem.js +4 -7
  197. package/esm/Button/Button.js +6 -9
  198. package/esm/ButtonGroup/ButtonGroup.js +6 -9
  199. package/esm/Calendar/Calendar.js +4 -7
  200. package/esm/Calendar/CalendarPanel.js +6 -9
  201. package/esm/Calendar/Header.js +4 -7
  202. package/esm/Calendar/MonthDropdown.js +10 -13
  203. package/esm/Calendar/MonthDropdownItem.js +6 -9
  204. package/esm/Calendar/Table.js +6 -9
  205. package/esm/Calendar/TableHeaderRow.js +4 -7
  206. package/esm/Calendar/TableRow.js +7 -10
  207. package/esm/Calendar/TimeDropdown.js +4 -7
  208. package/esm/Calendar/View.js +4 -7
  209. package/esm/Carousel/Carousel.js +10 -13
  210. package/esm/Cascader/Cascader.js +29 -26
  211. package/esm/Cascader/DropdownMenu.js +19 -21
  212. package/esm/CheckPicker/CheckPicker.js +33 -29
  213. package/esm/CheckTreePicker/CheckTreeNode.js +4 -6
  214. package/esm/CheckTreePicker/CheckTreePicker.js +47 -37
  215. package/esm/Checkbox/Checkbox.js +8 -12
  216. package/esm/CheckboxGroup/CheckboxGroup.d.ts +1 -12
  217. package/esm/CheckboxGroup/CheckboxGroup.js +5 -8
  218. package/esm/CheckboxGroup/CheckboxGroupContext.d.ts +13 -0
  219. package/esm/CheckboxGroup/CheckboxGroupContext.js +2 -0
  220. package/esm/CheckboxGroup/index.d.ts +4 -3
  221. package/esm/CheckboxGroup/index.js +2 -2
  222. package/esm/Col/Col.js +3 -2
  223. package/esm/Container/Container.js +4 -7
  224. package/esm/DOMHelper/index.d.ts +1 -1
  225. package/esm/DatePicker/DatePicker.js +27 -23
  226. package/esm/DatePicker/Toolbar.js +5 -8
  227. package/esm/DateRangePicker/Calendar.js +12 -13
  228. package/esm/DateRangePicker/DateRangePicker.js +40 -34
  229. package/esm/Divider/Divider.js +4 -7
  230. package/esm/Drawer/Drawer.js +8 -9
  231. package/esm/Dropdown/Dropdown.js +9 -12
  232. package/esm/Dropdown/DropdownItem.js +26 -22
  233. package/esm/Dropdown/DropdownMenu.js +3 -6
  234. package/esm/Dropdown/DropdownToggle.js +4 -7
  235. package/esm/FlexboxGrid/FlexboxGrid.js +8 -11
  236. package/esm/FlexboxGrid/FlexboxGridItem.js +8 -11
  237. package/esm/Form/Form.js +12 -15
  238. package/esm/FormControl/FormControl.js +6 -2
  239. package/esm/IconButton/IconButton.js +4 -7
  240. package/esm/Input/Input.js +6 -9
  241. package/esm/InputNumber/InputNumber.js +14 -17
  242. package/esm/InputPicker/InputAutosize.js +2 -4
  243. package/esm/InputPicker/InputPicker.js +32 -30
  244. package/esm/List/List.js +12 -15
  245. package/esm/List/ListItem.js +6 -9
  246. package/esm/Loader/Loader.js +6 -9
  247. package/esm/MaskedInput/MaskedInput.d.ts +43 -0
  248. package/esm/MaskedInput/MaskedInput.js +67 -0
  249. package/esm/MaskedInput/adjustCaretPosition.d.ts +11 -0
  250. package/esm/MaskedInput/adjustCaretPosition.js +213 -0
  251. package/esm/MaskedInput/conformToMask.d.ts +8 -0
  252. package/esm/MaskedInput/conformToMask.js +239 -0
  253. package/esm/MaskedInput/createTextMaskInputElement.d.ts +7 -0
  254. package/esm/MaskedInput/createTextMaskInputElement.js +212 -0
  255. package/esm/MaskedInput/index.d.ts +3 -0
  256. package/esm/MaskedInput/index.js +2 -0
  257. package/esm/MaskedInput/types.d.ts +10 -0
  258. package/esm/{@types/icons.js → MaskedInput/types.js} +0 -0
  259. package/esm/MaskedInput/utilities.d.ts +7 -0
  260. package/esm/MaskedInput/utilities.js +38 -0
  261. package/esm/Menu/Menu.d.ts +0 -1
  262. package/esm/Menu/Menu.js +3 -5
  263. package/esm/Message/Message.js +8 -11
  264. package/esm/Modal/Modal.d.ts +1 -10
  265. package/esm/Modal/Modal.js +31 -21
  266. package/esm/Modal/ModalBody.js +5 -8
  267. package/esm/Modal/ModalContext.d.ts +12 -0
  268. package/esm/Modal/ModalContext.js +2 -0
  269. package/esm/Modal/ModalDialog.js +8 -8
  270. package/esm/Modal/ModalHeader.js +7 -10
  271. package/esm/Modal/ModalTitle.d.ts +3 -2
  272. package/esm/Modal/ModalTitle.js +35 -4
  273. package/esm/MultiCascader/DropdownMenu.js +21 -23
  274. package/esm/MultiCascader/MultiCascader.js +35 -32
  275. package/esm/Nav/Nav.js +6 -9
  276. package/esm/Navbar/Navbar.js +6 -9
  277. package/esm/Notification/Notification.js +6 -9
  278. package/esm/Overlay/Modal.js +11 -18
  279. package/esm/Overlay/Overlay.js +2 -5
  280. package/esm/Overlay/OverlayTrigger.js +9 -9
  281. package/esm/Overlay/Position.js +4 -7
  282. package/esm/Overlay/positionUtils.js +1 -1
  283. package/esm/Pagination/Pagination.js +10 -13
  284. package/esm/Pagination/PaginationButton.js +4 -7
  285. package/esm/Pagination/PaginationGroup.js +10 -11
  286. package/esm/Panel/Panel.js +6 -9
  287. package/esm/PanelGroup/PanelGroup.js +4 -7
  288. package/esm/Picker/DropdownMenu.js +2 -3
  289. package/esm/Picker/DropdownMenuGroup.js +4 -7
  290. package/esm/Picker/DropdownMenuItem.js +4 -7
  291. package/esm/Picker/PickerToggle.js +13 -12
  292. package/esm/Picker/propTypes.d.ts +2 -16
  293. package/esm/Picker/propTypes.js +2 -13
  294. package/esm/Picker/utils.js +14 -9
  295. package/esm/Placeholder/PlaceholderGraph.js +6 -9
  296. package/esm/Placeholder/PlaceholderGrid.js +12 -15
  297. package/esm/Placeholder/PlaceholderParagraph.js +10 -13
  298. package/esm/Popover/Popover.js +4 -7
  299. package/esm/Progress/ProgressCircle.js +18 -21
  300. package/esm/Progress/ProgressLine.js +8 -11
  301. package/esm/Radio/Radio.js +6 -10
  302. package/esm/RadioGroup/RadioGroup.js +6 -9
  303. package/esm/RangeSlider/RangeSlider.js +17 -20
  304. package/esm/Rate/Character.js +4 -7
  305. package/esm/Rate/Rate.js +14 -17
  306. package/esm/Ripple/Ripple.js +4 -7
  307. package/esm/SelectPicker/SelectPicker.js +31 -28
  308. package/esm/Sidebar/Sidebar.js +6 -9
  309. package/esm/Sidenav/Sidenav.js +8 -11
  310. package/esm/Sidenav/SidenavDropdown.d.ts +6 -1
  311. package/esm/Sidenav/SidenavDropdown.js +19 -18
  312. package/esm/Sidenav/SidenavDropdownCollapse.js +2 -5
  313. package/esm/Sidenav/SidenavDropdownItem.js +5 -8
  314. package/esm/Sidenav/SidenavDropdownMenu.js +5 -8
  315. package/esm/Sidenav/SidenavToggle.js +4 -7
  316. package/esm/Slider/Graduated.js +4 -7
  317. package/esm/Slider/Handle.d.ts +2 -0
  318. package/esm/Slider/Handle.js +23 -12
  319. package/esm/Slider/Input.d.ts +3 -0
  320. package/esm/Slider/Input.js +23 -0
  321. package/esm/Slider/Mark.js +4 -7
  322. package/esm/Slider/ProgressBar.js +4 -7
  323. package/esm/Slider/Slider.d.ts +0 -3
  324. package/esm/Slider/Slider.js +14 -22
  325. package/esm/Steps/StepItem.js +4 -7
  326. package/esm/Steps/Steps.js +8 -11
  327. package/esm/Table/Table.d.ts +7 -7
  328. package/esm/Table/Table.js +5 -5
  329. package/esm/TagInput/index.js +4 -6
  330. package/esm/TagPicker/index.d.ts +1 -1
  331. package/esm/TagPicker/index.js +4 -6
  332. package/esm/Timeline/Timeline.js +6 -10
  333. package/esm/Timeline/TimelineItem.js +4 -7
  334. package/esm/Toggle/Toggle.d.ts +2 -0
  335. package/esm/Toggle/Toggle.js +27 -13
  336. package/esm/Tooltip/Tooltip.js +4 -7
  337. package/esm/Tree/Tree.d.ts +6 -0
  338. package/esm/TreePicker/TreeNode.js +4 -6
  339. package/esm/TreePicker/TreePicker.js +38 -31
  340. package/esm/Uploader/UploadFileItem.d.ts +1 -0
  341. package/esm/Uploader/UploadFileItem.js +42 -33
  342. package/esm/Uploader/UploadTrigger.js +4 -7
  343. package/esm/Uploader/Uploader.d.ts +2 -0
  344. package/esm/Uploader/Uploader.js +28 -28
  345. package/esm/index.d.ts +2 -0
  346. package/esm/index.js +1 -0
  347. package/esm/locales/fa_IR.d.ts +105 -0
  348. package/esm/locales/fa_IR.js +74 -0
  349. package/esm/locales/index.d.ts +1 -0
  350. package/esm/locales/index.js +2 -1
  351. package/esm/toaster/ToastContainer.js +6 -9
  352. package/esm/utils/createComponent.d.ts +1 -2
  353. package/esm/utils/createComponent.js +10 -13
  354. package/esm/utils/previewFile.d.ts +1 -0
  355. package/esm/utils/previewFile.js +9 -0
  356. package/esm/utils/useUniqueId.d.ts +3 -1
  357. package/esm/utils/useUniqueId.js +4 -2
  358. package/locales/fa_IR/package.json +7 -0
  359. package/package.json +6 -8
  360. package/styles/color-modes/dark.less +1 -0
  361. package/styles/color-modes/high-contrast.less +1 -0
  362. package/styles/color-modes/light.less +3 -0
  363. package/styles/variables.less +3 -1
  364. package/cjs/@types/icons.d.ts +0 -1
  365. package/esm/@types/icons.d.ts +0 -1
@@ -0,0 +1,212 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import isString from 'lodash/isString';
3
+ import isNumber from 'lodash/isNumber';
4
+ import adjustCaretPosition from './adjustCaretPosition';
5
+ import conformToMask from './conformToMask';
6
+ import { convertMaskToPlaceholder, processCaretTraps, defaultPlaceholderChar } from './utilities';
7
+ var emptyString = '';
8
+ var strNone = 'none';
9
+ var strObject = 'object';
10
+ var isAndroid = typeof navigator !== 'undefined' && /Android/i.test(navigator.userAgent);
11
+ var defer = typeof requestAnimationFrame !== 'undefined' ? requestAnimationFrame : setTimeout;
12
+ export default function createTextMaskInputElement(config) {
13
+ // Anything that we will need to keep between `update` calls, we will store in this `state` object.
14
+ var state = {
15
+ previousConformedValue: undefined,
16
+ previousPlaceholder: undefined
17
+ };
18
+ return {
19
+ state: state,
20
+ // `update` is called by framework components whenever they want to update the `value` of the input element.
21
+ // The caller can send a `rawValue` to be conformed and set on the input element. However, the default use-case
22
+ // is for this to be read from the `inputElement` directly.
23
+ update: function update(rawValue, _temp) {
24
+ var _pipeResults, _pipeResults2;
25
+
26
+ var _ref = _temp === void 0 ? config : _temp,
27
+ inputElement = _ref.inputElement,
28
+ providedMask = _ref.mask,
29
+ guide = _ref.guide,
30
+ pipe = _ref.pipe,
31
+ _ref$placeholderChar = _ref.placeholderChar,
32
+ placeholderChar = _ref$placeholderChar === void 0 ? defaultPlaceholderChar : _ref$placeholderChar,
33
+ _ref$keepCharPosition = _ref.keepCharPositions,
34
+ keepCharPositions = _ref$keepCharPosition === void 0 ? false : _ref$keepCharPosition,
35
+ _ref$showMask = _ref.showMask,
36
+ showMask = _ref$showMask === void 0 ? false : _ref$showMask;
37
+
38
+ // if `rawValue` is `undefined`, read from the `inputElement`
39
+ if (typeof rawValue === 'undefined') {
40
+ rawValue = inputElement.value;
41
+ } // If `rawValue` equals `state.previousConformedValue`, we don't need to change anything. So, we return.
42
+ // This check is here to handle controlled framework components that repeat the `update` call on every render.
43
+
44
+
45
+ if (rawValue === state.previousConformedValue) {
46
+ return;
47
+ } // Text Mask accepts masks that are a combination of a `mask` and a `pipe` that work together. If such a `mask` is
48
+ // passed, we destructure it below, so the rest of the code can work normally as if a separate `mask` and a `pipe`
49
+ // were passed.
50
+
51
+
52
+ if (typeof providedMask === strObject && providedMask.pipe !== undefined && providedMask.mask !== undefined) {
53
+ pipe = providedMask.pipe;
54
+ providedMask = providedMask.mask;
55
+ } // The `placeholder` is an essential piece of how Text Mask works. For a mask like `(111)`, the placeholder would
56
+ // be `(___)` if the `placeholderChar` is set to `_`.
57
+
58
+
59
+ var placeholder; // We don't know what the mask would be yet. If it is an array, we take it as is, but if it's a function, we will
60
+ // have to call that function to get the mask array.
61
+
62
+ var mask; // If the provided mask is an array, we can call `convertMaskToPlaceholder` here once and we'll always have the
63
+ // correct `placeholder`.
64
+
65
+ if (providedMask instanceof Array) {
66
+ placeholder = convertMaskToPlaceholder(providedMask, placeholderChar);
67
+ } // In framework components that support reactivity, it's possible to turn off masking by passing
68
+ // `false` for `mask` after initialization. See https://github.com/text-mask/text-mask/pull/359
69
+
70
+
71
+ if (providedMask === false) {
72
+ return;
73
+ } // We check the provided `rawValue` before moving further.
74
+ // If it's something we can't work with `getSafeRawValue` will throw.
75
+
76
+
77
+ var safeRawValue = getSafeRawValue(rawValue); // `selectionEnd` indicates to us where the caret position is after the user has typed into the input
78
+
79
+ var currentCaretPosition = inputElement.selectionEnd; // We need to know what the `previousConformedValue` and `previousPlaceholder` is from the previous `update` call
80
+
81
+ var previousConformedValue = state.previousConformedValue,
82
+ previousPlaceholder = state.previousPlaceholder;
83
+ var caretTrapIndexes; // If the `providedMask` is a function. We need to call it at every `update` to get the `mask` array.
84
+ // Then we also need to get the `placeholder`
85
+
86
+ if (typeof providedMask === 'function') {
87
+ mask = providedMask(safeRawValue, {
88
+ currentCaretPosition: currentCaretPosition,
89
+ previousConformedValue: previousConformedValue,
90
+ placeholderChar: placeholderChar
91
+ }); // disable masking if `mask` is `false`
92
+
93
+ if (mask === false) {
94
+ return;
95
+ } // mask functions can setup caret traps to have some control over how the caret moves. We need to process
96
+ // the mask for any caret traps. `processCaretTraps` will remove the caret traps from the mask and return
97
+ // the indexes of the caret traps.
98
+
99
+
100
+ var _processCaretTraps = processCaretTraps(mask),
101
+ maskWithoutCaretTraps = _processCaretTraps.maskWithoutCaretTraps,
102
+ indexes = _processCaretTraps.indexes;
103
+
104
+ mask = maskWithoutCaretTraps; // The processed mask is what we're interested in
105
+
106
+ caretTrapIndexes = indexes; // And we need to store these indexes because they're needed by `adjustCaretPosition`
107
+
108
+ placeholder = convertMaskToPlaceholder(mask, placeholderChar); // If the `providedMask` is not a function, we just use it as-is.
109
+ } else {
110
+ mask = providedMask;
111
+ } // The following object will be passed to `conformToMask` to determine how the `rawValue` will be conformed
112
+
113
+
114
+ var conformToMaskConfig = {
115
+ previousConformedValue: previousConformedValue,
116
+ guide: guide,
117
+ placeholderChar: placeholderChar,
118
+ pipe: pipe,
119
+ placeholder: placeholder,
120
+ currentCaretPosition: currentCaretPosition,
121
+ keepCharPositions: keepCharPositions
122
+ }; // `conformToMask` returns `conformedValue` as part of an object for future API flexibility
123
+
124
+ var _conformToMask = conformToMask(safeRawValue, mask, conformToMaskConfig),
125
+ conformedValue = _conformToMask.conformedValue; // The following few lines are to support the `pipe` feature.
126
+
127
+
128
+ var piped = typeof pipe === 'function';
129
+ var pipeResults = {}; // If `pipe` is a function, we call it.
130
+
131
+ if (piped) {
132
+ // `pipe` receives the `conformedValue` and the configurations with which `conformToMask` was called.
133
+ pipeResults = pipe(conformedValue, _extends({
134
+ rawValue: safeRawValue
135
+ }, conformToMaskConfig)); // `pipeResults` should be an object. But as a convenience, we allow the pipe author to just return `false` to
136
+ // indicate rejection. Or return just a string when there are no piped characters.
137
+ // If the `pipe` returns `false` or a string, the block below turns it into an object that the rest
138
+ // of the code can work with.
139
+
140
+ if (pipeResults === false) {
141
+ // If the `pipe` rejects `conformedValue`, we use the `previousConformedValue`, and set `rejected` to `true`.
142
+ pipeResults = {
143
+ value: previousConformedValue,
144
+ rejected: true
145
+ };
146
+ } else if (isString(pipeResults)) {
147
+ pipeResults = {
148
+ value: pipeResults
149
+ };
150
+ }
151
+ } // Before we proceed, we need to know which conformed value to use, the one returned by the pipe or the one
152
+ // returned by `conformToMask`.
153
+
154
+
155
+ var finalConformedValue = piped ? (_pipeResults = pipeResults) === null || _pipeResults === void 0 ? void 0 : _pipeResults.value : conformedValue; // After determining the conformed value, we will need to know where to set
156
+ // the caret position. `adjustCaretPosition` will tell us.
157
+
158
+ var adjustedCaretPosition = adjustCaretPosition({
159
+ previousConformedValue: previousConformedValue,
160
+ previousPlaceholder: previousPlaceholder,
161
+ conformedValue: finalConformedValue,
162
+ placeholder: placeholder,
163
+ rawValue: safeRawValue,
164
+ currentCaretPosition: currentCaretPosition,
165
+ placeholderChar: placeholderChar,
166
+ indexesOfPipedChars: (_pipeResults2 = pipeResults) === null || _pipeResults2 === void 0 ? void 0 : _pipeResults2.indexesOfPipedChars,
167
+ caretTrapIndexes: caretTrapIndexes
168
+ }); // Text Mask sets the input value to an empty string when the condition below is set. It provides a better UX.
169
+
170
+ var inputValueShouldBeEmpty = finalConformedValue === placeholder && adjustedCaretPosition === 0;
171
+ var emptyValue = showMask ? placeholder : emptyString;
172
+ var inputElementValue = inputValueShouldBeEmpty ? emptyValue : finalConformedValue;
173
+ state.previousConformedValue = inputElementValue; // store value for access for next time
174
+
175
+ state.previousPlaceholder = placeholder; // In some cases, this `update` method will be repeatedly called with a raw value that has already been conformed
176
+ // and set to `inputElement.value`. The below check guards against needlessly readjusting the input state.
177
+ // See https://github.com/text-mask/text-mask/issues/231
178
+
179
+ if (inputElement.value === inputElementValue) {
180
+ return;
181
+ }
182
+
183
+ inputElement.value = inputElementValue; // set the input value
184
+
185
+ safeSetSelection(inputElement, adjustedCaretPosition); // adjust caret position
186
+ }
187
+ };
188
+ }
189
+
190
+ function safeSetSelection(element, selectionPosition) {
191
+ if (document.activeElement === element) {
192
+ if (isAndroid) {
193
+ defer(function () {
194
+ return element.setSelectionRange(selectionPosition, selectionPosition, strNone);
195
+ }, 0);
196
+ } else {
197
+ element.setSelectionRange(selectionPosition, selectionPosition, strNone);
198
+ }
199
+ }
200
+ }
201
+
202
+ function getSafeRawValue(inputValue) {
203
+ if (isString(inputValue)) {
204
+ return inputValue;
205
+ } else if (isNumber(inputValue)) {
206
+ return String(inputValue);
207
+ } else if (inputValue === undefined || inputValue === null) {
208
+ return emptyString;
209
+ } else {
210
+ throw new Error("The 'value' provided to Text Mask needs to be a string or a number. The value received was:\n\n " + JSON.stringify(inputValue));
211
+ }
212
+ }
@@ -0,0 +1,3 @@
1
+ import MaskedInput from './MaskedInput';
2
+ export type { MaskedInputProps } from './MaskedInput';
3
+ export default MaskedInput;
@@ -0,0 +1,2 @@
1
+ import MaskedInput from './MaskedInput';
2
+ export default MaskedInput;
@@ -0,0 +1,10 @@
1
+ export interface ConfigType {
2
+ guide?: boolean;
3
+ previousConformedValue?: string;
4
+ placeholderChar?: string;
5
+ placeholder?: string;
6
+ currentCaretPosition?: number;
7
+ keepCharPositions?: boolean;
8
+ }
9
+ export declare type MaskType = string | (string | RegExp)[];
10
+ export declare type MaskFunctionType = (rawValue: string, config: ConfigType) => MaskType;
File without changes
@@ -0,0 +1,7 @@
1
+ import { MaskType, MaskFunctionType } from './types';
2
+ export declare const defaultPlaceholderChar = "_";
3
+ export declare function convertMaskToPlaceholder(mask?: MaskType | MaskFunctionType, placeholderChar?: string): string;
4
+ export declare function processCaretTraps(mask: any): {
5
+ maskWithoutCaretTraps: any;
6
+ indexes: any[];
7
+ };
@@ -0,0 +1,38 @@
1
+ var emptyArray = [];
2
+ var strCaretTrap = '[]';
3
+ export var defaultPlaceholderChar = '_';
4
+ export function convertMaskToPlaceholder(mask, placeholderChar) {
5
+ if (mask === void 0) {
6
+ mask = emptyArray;
7
+ }
8
+
9
+ if (placeholderChar === void 0) {
10
+ placeholderChar = defaultPlaceholderChar;
11
+ }
12
+
13
+ if (!Array.isArray(mask)) {
14
+ throw new Error('Text-mask:convertMaskToPlaceholder; The mask property must be an array.');
15
+ }
16
+
17
+ if (mask.indexOf(placeholderChar) !== -1) {
18
+ throw new Error('Placeholder character must not be used as part of the mask. Please specify a character ' + 'that is not present in your mask as your placeholder character.\n\n' + ("The placeholder character that was received is: " + JSON.stringify(placeholderChar) + "\n\n") + ("The mask that was received is: " + JSON.stringify(mask)));
19
+ }
20
+
21
+ return mask.map(function (char) {
22
+ return char instanceof RegExp ? placeholderChar : char;
23
+ }).join('');
24
+ }
25
+ export function processCaretTraps(mask) {
26
+ var indexes = [];
27
+ var indexOfCaretTrap;
28
+
29
+ while (indexOfCaretTrap = mask.indexOf(strCaretTrap), indexOfCaretTrap !== -1) {
30
+ indexes.push(indexOfCaretTrap);
31
+ mask.splice(indexOfCaretTrap, 1);
32
+ }
33
+
34
+ return {
35
+ maskWithoutCaretTraps: mask,
36
+ indexes: indexes
37
+ };
38
+ }
@@ -29,7 +29,6 @@ export interface MenuHandle {
29
29
  declare function Menu(props: MenuProps & React.HTMLAttributes<HTMLUListElement>): React.ReactElement<React.HTMLAttributes<HTMLDivElement>, string | React.JSXElementConstructor<any>>;
30
30
  declare namespace Menu {
31
31
  var displayName: string;
32
- var defaultProps: Partial<MenuProps>;
33
32
  var propTypes: {
34
33
  children: PropTypes.Validator<(...args: any[]) => any>;
35
34
  };
package/esm/Menu/Menu.js CHANGED
@@ -9,9 +9,7 @@ import useFocus from '../utils/useFocus';
9
9
  import useClickOutside from '../utils/useClickOutside';
10
10
  import { isFocusLeaving } from '../utils/events';
11
11
  import { isFocusableElement } from '../utils/dom';
12
- var defaultProps = {
13
- openMenuOn: ['click']
14
- };
12
+ var defaultOpenMenuOn = ['click'];
15
13
  /**
16
14
  * Headless ARIA `menu`
17
15
  */
@@ -21,7 +19,8 @@ function Menu(props) {
21
19
 
22
20
  var disabled = props.disabled,
23
21
  children = props.children,
24
- openMenuOn = props.openMenuOn,
22
+ _props$openMenuOn = props.openMenuOn,
23
+ openMenuOn = _props$openMenuOn === void 0 ? defaultOpenMenuOn : _props$openMenuOn,
25
24
  menuButtonText = props.menuButtonText,
26
25
  renderMenuButton = props.renderMenuButton,
27
26
  renderMenuPopup = props.renderMenuPopup,
@@ -368,7 +367,6 @@ function Menu(props) {
368
367
  }
369
368
 
370
369
  Menu.displayName = 'Menu';
371
- Menu.defaultProps = defaultProps;
372
370
  Menu.propTypes = {
373
371
  children: PropTypes.func.isRequired
374
372
  };
@@ -8,24 +8,22 @@ import React, { useState } from 'react';
8
8
  import PropTypes from 'prop-types';
9
9
  import { useClassNames, useTimeout, MESSAGE_STATUS_ICONS, STATUS } from '../utils';
10
10
  import CloseButton from '../CloseButton';
11
- var defaultProps = {
12
- as: 'div',
13
- classPrefix: 'message',
14
- type: 'info',
15
- duration: 2000
16
- };
17
11
  var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
18
12
  var _withClassPrefix;
19
13
 
20
- var Component = props.as,
14
+ var _props$as = props.as,
15
+ Component = _props$as === void 0 ? 'div' : _props$as,
21
16
  className = props.className,
22
- classPrefix = props.classPrefix,
17
+ _props$classPrefix = props.classPrefix,
18
+ classPrefix = _props$classPrefix === void 0 ? 'message' : _props$classPrefix,
23
19
  children = props.children,
24
20
  closable = props.closable,
25
- duration = props.duration,
21
+ _props$duration = props.duration,
22
+ duration = _props$duration === void 0 ? 2000 : _props$duration,
26
23
  full = props.full,
27
24
  header = props.header,
28
- type = props.type,
25
+ _props$type = props.type,
26
+ type = _props$type === void 0 ? 'info' : _props$type,
29
27
  showIcon = props.showIcon,
30
28
  onClose = props.onClose,
31
29
  rest = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "children", "closable", "duration", "full", "header", "type", "showIcon", "onClose"]);
@@ -80,7 +78,6 @@ var Message = /*#__PURE__*/React.forwardRef(function (props, ref) {
80
78
  }, children))));
81
79
  });
82
80
  Message.displayName = 'Message';
83
- Message.defaultProps = defaultProps;
84
81
  Message.propTypes = {
85
82
  type: PropTypes.oneOf(STATUS),
86
83
  className: PropTypes.string,
@@ -6,7 +6,7 @@ import ModalHeader from './ModalHeader';
6
6
  import ModalTitle from './ModalTitle';
7
7
  import ModalFooter from './ModalFooter';
8
8
  import { TypeAttributes, RsRefForwardingComponent } from '../@types/common';
9
- export interface ModalProps extends BaseModalProps {
9
+ export interface ModalProps extends BaseModalProps, Pick<React.HTMLAttributes<HTMLElement>, 'role' | 'id' | 'aria-labelledby' | 'aria-describedby'> {
10
10
  /** A modal can have different sizes */
11
11
  size?: TypeAttributes.Size;
12
12
  /** Set the duration of the animation */
@@ -26,15 +26,6 @@ export interface ModalProps extends BaseModalProps {
26
26
  /** Render Modal as Drawer */
27
27
  drawer?: boolean;
28
28
  }
29
- export interface ModalContextProps {
30
- /** Pass the close event callback to the header close button. */
31
- onModalClose: (event: React.MouseEvent<Element, MouseEvent>) => void;
32
- /** Pass the latest style to body. */
33
- getBodyStyles?: () => React.CSSProperties;
34
- /** Whether this Modal is a Drawer */
35
- isDrawer: boolean;
36
- }
37
- export declare const ModalContext: React.Context<ModalContextProps>;
38
29
  interface ModalComponent extends RsRefForwardingComponent<'div', ModalProps> {
39
30
  Body: typeof ModalBody;
40
31
  Header: typeof ModalHeader;
@@ -11,44 +11,48 @@ import BaseModal, { modalPropTypes } from '../Overlay/Modal';
11
11
  import Bounce from '../Animation/Bounce';
12
12
  import { useClassNames, mergeRefs, SIZE } from '../utils';
13
13
  import ModalDialog, { modalDialogPropTypes } from './ModalDialog';
14
+ import { ModalContext } from './ModalContext';
14
15
  import ModalBody from './ModalBody';
15
16
  import ModalHeader from './ModalHeader';
16
17
  import ModalTitle from './ModalTitle';
17
18
  import ModalFooter from './ModalFooter';
18
19
  import helper from '../DOMHelper';
19
20
  import { useBodyStyles } from './utils';
20
- var defaultProps = {
21
- classPrefix: 'modal',
22
- size: 'sm',
23
- animation: Bounce,
24
- animationTimeout: 300,
25
- dialogAs: ModalDialog,
26
- backdrop: true,
27
- overflow: true
28
- };
29
- export var ModalContext = /*#__PURE__*/React.createContext(null);
21
+ import useUniqueId from '../utils/useUniqueId';
30
22
  var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
31
23
  var className = props.className,
32
24
  children = props.children,
33
- classPrefix = props.classPrefix,
25
+ _props$classPrefix = props.classPrefix,
26
+ classPrefix = _props$classPrefix === void 0 ? 'modal' : _props$classPrefix,
34
27
  dialogClassName = props.dialogClassName,
35
28
  backdropClassName = props.backdropClassName,
36
- backdrop = props.backdrop,
29
+ _props$backdrop = props.backdrop,
30
+ backdrop = _props$backdrop === void 0 ? true : _props$backdrop,
37
31
  dialogStyle = props.dialogStyle,
38
- animation = props.animation,
32
+ _props$animation = props.animation,
33
+ animation = _props$animation === void 0 ? Bounce : _props$animation,
39
34
  open = props.open,
40
- size = props.size,
35
+ _props$size = props.size,
36
+ size = _props$size === void 0 ? 'sm' : _props$size,
41
37
  full = props.full,
42
- Dialog = props.dialogAs,
38
+ _props$dialogAs = props.dialogAs,
39
+ Dialog = _props$dialogAs === void 0 ? ModalDialog : _props$dialogAs,
43
40
  animationProps = props.animationProps,
44
- animationTimeout = props.animationTimeout,
45
- overflow = props.overflow,
41
+ _props$animationTimeo = props.animationTimeout,
42
+ animationTimeout = _props$animationTimeo === void 0 ? 300 : _props$animationTimeo,
43
+ _props$overflow = props.overflow,
44
+ overflow = _props$overflow === void 0 ? true : _props$overflow,
46
45
  drawer = props.drawer,
47
46
  onClose = props.onClose,
48
47
  onEntered = props.onEntered,
49
48
  onEntering = props.onEntering,
50
49
  onExited = props.onExited,
51
- rest = _objectWithoutPropertiesLoose(props, ["className", "children", "classPrefix", "dialogClassName", "backdropClassName", "backdrop", "dialogStyle", "animation", "open", "size", "full", "dialogAs", "animationProps", "animationTimeout", "overflow", "drawer", "onClose", "onEntered", "onEntering", "onExited"]);
50
+ _props$role = props.role,
51
+ role = _props$role === void 0 ? 'dialog' : _props$role,
52
+ idProp = props.id,
53
+ ariaLabelledby = props['aria-labelledby'],
54
+ ariaDescribedby = props['aria-describedby'],
55
+ rest = _objectWithoutPropertiesLoose(props, ["className", "children", "classPrefix", "dialogClassName", "backdropClassName", "backdrop", "dialogStyle", "animation", "open", "size", "full", "dialogAs", "animationProps", "animationTimeout", "overflow", "drawer", "onClose", "onEntered", "onEntering", "onExited", "role", "id", "aria-labelledby", "aria-describedby"]);
52
56
 
53
57
  var inClass = {
54
58
  in: open && !animation
@@ -73,15 +77,17 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
73
77
  onChangeBodyStyles = _useBodyStyles[1],
74
78
  onDestroyEvents = _useBodyStyles[2];
75
79
 
80
+ var dialogId = useUniqueId('dialog-', idProp);
76
81
  var modalContextValue = useMemo(function () {
77
82
  return {
83
+ dialogId: dialogId,
78
84
  onModalClose: onClose,
79
85
  getBodyStyles: function getBodyStyles() {
80
86
  return bodyStyles;
81
87
  },
82
88
  isDrawer: drawer
83
89
  };
84
- }, [onClose, bodyStyles, drawer]);
90
+ }, [dialogId, onClose, bodyStyles, drawer]);
85
91
 
86
92
  var _useState = useState(false),
87
93
  shake = _useState[0],
@@ -141,7 +147,12 @@ var Modal = /*#__PURE__*/React.forwardRef(function (props, ref) {
141
147
  var transitionClassName = transitionProps.className,
142
148
  transitionRest = _objectWithoutPropertiesLoose(transitionProps, ["className"]);
143
149
 
144
- return /*#__PURE__*/React.createElement(Dialog, _extends({}, transitionRest, pick(rest, Object.keys(modalDialogPropTypes)), {
150
+ return /*#__PURE__*/React.createElement(Dialog, _extends({
151
+ role: role,
152
+ id: dialogId,
153
+ "aria-labelledby": ariaLabelledby !== null && ariaLabelledby !== void 0 ? ariaLabelledby : dialogId + "-title",
154
+ "aria-describedby": ariaDescribedby
155
+ }, transitionRest, pick(rest, Object.keys(modalDialogPropTypes)), {
145
156
  ref: mergeRefs(dialogRef, transitionRef),
146
157
  classPrefix: classPrefix,
147
158
  className: merge(classes, transitionClassName, prefix({
@@ -158,7 +169,6 @@ Modal.Title = ModalTitle;
158
169
  Modal.Footer = ModalFooter;
159
170
  Modal.Dialog = ModalDialog;
160
171
  Modal.displayName = 'Modal';
161
- Modal.defaultProps = defaultProps;
162
172
  Modal.propTypes = _extends({}, modalPropTypes, {
163
173
  animation: PropTypes.any,
164
174
  animationTimeout: PropTypes.number,
@@ -3,16 +3,14 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  import React from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { useClassNames } from '../utils';
6
- import { ModalContext } from './Modal';
6
+ import { ModalContext } from './ModalContext';
7
7
  import IconButton from '../IconButton';
8
8
  import Close from '@rsuite/icons/Close';
9
- var defaultProps = {
10
- as: 'div',
11
- classPrefix: 'modal-body'
12
- };
13
9
  var ModalBody = /*#__PURE__*/React.forwardRef(function (props, ref) {
14
- var Component = props.as,
15
- classPrefix = props.classPrefix,
10
+ var _props$as = props.as,
11
+ Component = _props$as === void 0 ? 'div' : _props$as,
12
+ _props$classPrefix = props.classPrefix,
13
+ classPrefix = _props$classPrefix === void 0 ? 'modal-body' : _props$classPrefix,
16
14
  className = props.className,
17
15
  style = props.style,
18
16
  children = props.children,
@@ -42,7 +40,6 @@ var ModalBody = /*#__PURE__*/React.forwardRef(function (props, ref) {
42
40
  });
43
41
  });
44
42
  ModalBody.displayName = 'ModalBody';
45
- ModalBody.defaultProps = defaultProps;
46
43
  ModalBody.propTypes = {
47
44
  as: PropTypes.elementType,
48
45
  classPrefix: PropTypes.string,
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export interface ModalContextProps {
3
+ /** ID of the dialog element */
4
+ dialogId: string;
5
+ /** Pass the close event callback to the header close button. */
6
+ onModalClose: (event: React.MouseEvent<Element, MouseEvent>) => void;
7
+ /** Pass the latest style to body. */
8
+ getBodyStyles?: () => React.CSSProperties;
9
+ /** Whether this Modal is a Drawer */
10
+ isDrawer: boolean;
11
+ }
12
+ export declare const ModalContext: React.Context<ModalContextProps>;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export var ModalContext = /*#__PURE__*/React.createContext(null);
@@ -16,17 +16,15 @@ export var modalDialogPropTypes = {
16
16
  dialogStyle: PropTypes.object,
17
17
  children: PropTypes.node
18
18
  };
19
- var defaultProps = {
20
- as: 'div',
21
- classPrefix: 'modal'
22
- };
23
19
  var ModalDialog = /*#__PURE__*/React.forwardRef(function (props, ref) {
24
- var Component = props.as,
20
+ var _props$as = props.as,
21
+ Component = _props$as === void 0 ? 'div' : _props$as,
25
22
  style = props.style,
26
23
  children = props.children,
27
24
  dialogClassName = props.dialogClassName,
28
25
  dialogStyle = props.dialogStyle,
29
- classPrefix = props.classPrefix,
26
+ _props$classPrefix = props.classPrefix,
27
+ classPrefix = _props$classPrefix === void 0 ? 'modal' : _props$classPrefix,
30
28
  className = props.className,
31
29
  size = props.size,
32
30
  rest = _objectWithoutPropertiesLoose(props, ["as", "style", "children", "dialogClassName", "dialogStyle", "classPrefix", "className", "size"]);
@@ -42,7 +40,10 @@ var ModalDialog = /*#__PURE__*/React.forwardRef(function (props, ref) {
42
40
 
43
41
  var classes = merge(className, withClassPrefix(size));
44
42
  var dialogClasses = merge(dialogClassName, prefix('dialog'));
45
- return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
43
+ return /*#__PURE__*/React.createElement(Component, _extends({
44
+ role: "dialog",
45
+ "aria-modal": true
46
+ }, rest, {
46
47
  ref: ref,
47
48
  className: classes,
48
49
  style: modalStyle
@@ -55,6 +56,5 @@ var ModalDialog = /*#__PURE__*/React.forwardRef(function (props, ref) {
55
56
  }, children)));
56
57
  });
57
58
  ModalDialog.displayName = 'ModalDialog';
58
- ModalDialog.defaultProps = defaultProps;
59
59
  ModalDialog.propTypes = modalDialogPropTypes;
60
60
  export default ModalDialog;
@@ -3,20 +3,18 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  import React, { useContext } from 'react';
4
4
  import PropTypes from 'prop-types';
5
5
  import { createChainedFunction, useClassNames } from '../utils';
6
- import { ModalContext } from './Modal';
6
+ import { ModalContext } from './ModalContext';
7
7
  import CloseButton from '../CloseButton';
8
8
  import Close from '@rsuite/icons/Close';
9
9
  import IconButton from '../IconButton';
10
- var defaultProps = {
11
- as: 'div',
12
- closeButton: true,
13
- classPrefix: 'modal-header'
14
- };
15
10
  var ModalHeader = /*#__PURE__*/React.forwardRef(function (props, ref) {
16
- var Component = props.as,
17
- classPrefix = props.classPrefix,
11
+ var _props$as = props.as,
12
+ Component = _props$as === void 0 ? 'div' : _props$as,
13
+ _props$classPrefix = props.classPrefix,
14
+ classPrefix = _props$classPrefix === void 0 ? 'modal-header' : _props$classPrefix,
18
15
  className = props.className,
19
- closeButton = props.closeButton,
16
+ _props$closeButton = props.closeButton,
17
+ closeButton = _props$closeButton === void 0 ? true : _props$closeButton,
20
18
  children = props.children,
21
19
  onClose = props.onClose,
22
20
  rest = _objectWithoutPropertiesLoose(props, ["as", "classPrefix", "className", "closeButton", "children", "onClose"]);
@@ -44,7 +42,6 @@ var ModalHeader = /*#__PURE__*/React.forwardRef(function (props, ref) {
44
42
  }), closeButton && buttonElement, children);
45
43
  });
46
44
  ModalHeader.displayName = 'ModalHeader';
47
- ModalHeader.defaultProps = defaultProps;
48
45
  ModalHeader.propTypes = {
49
46
  as: PropTypes.elementType,
50
47
  classPrefix: PropTypes.string,
@@ -1,4 +1,5 @@
1
- import { ComponentProps } from '../utils/createComponent';
1
+ import type { ComponentProps } from '../utils/createComponent';
2
+ import type { RsRefForwardingComponent } from '../@types/common';
2
3
  export declare type ModalTitleProps = ComponentProps;
3
- declare const ModalTitle: import("../@types/common").RsRefForwardingComponent<"div", ComponentProps>;
4
+ declare const ModalTitle: RsRefForwardingComponent<'h4', ComponentProps>;
4
5
  export default ModalTitle;