@react-ui-org/react-ui 0.64.1 → 0.66.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 (311) hide show
  1. package/README.md +3 -6
  2. package/dist/react-ui.css +16 -16
  3. package/dist/react-ui.d.ts +1936 -0
  4. package/dist/react-ui.development.css +3591 -3003
  5. package/dist/react-ui.development.js +2028 -1060
  6. package/dist/react-ui.js +1 -1
  7. package/package.json +74 -70
  8. package/src/components/Alert/{Alert.jsx → Alert.tsx} +8 -43
  9. package/src/components/Alert/Alert.types.ts +34 -0
  10. package/src/components/Alert/README.md +1 -1
  11. package/src/components/Alert/index.ts +2 -0
  12. package/src/components/Badge/Badge.tsx +30 -0
  13. package/src/components/Badge/Badge.types.ts +24 -0
  14. package/src/components/Badge/README.md +1 -1
  15. package/src/components/Badge/index.ts +5 -0
  16. package/src/components/Button/Button.tsx +110 -0
  17. package/src/components/Button/Button.types.ts +93 -0
  18. package/src/components/Button/README.md +1 -1
  19. package/src/components/Button/helpers/{getRootLabelVisibilityClassName.js → getRootLabelVisibilityClassName.ts} +5 -2
  20. package/src/components/Button/index.ts +6 -0
  21. package/src/components/ButtonGroup/{ButtonGroup.jsx → ButtonGroup.tsx} +9 -40
  22. package/src/components/ButtonGroup/ButtonGroup.types.ts +45 -0
  23. package/src/components/ButtonGroup/ButtonGroupContext.ts +4 -0
  24. package/src/components/ButtonGroup/README.md +1 -1
  25. package/src/components/ButtonGroup/{index.js → index.ts} +4 -0
  26. package/src/components/Card/Card.tsx +33 -0
  27. package/src/components/Card/Card.types.ts +46 -0
  28. package/src/components/Card/{CardBody.jsx → CardBody.tsx} +4 -11
  29. package/src/components/Card/{CardFooter.jsx → CardFooter.tsx} +4 -15
  30. package/src/components/Card/README.md +6 -7
  31. package/src/components/Card/{index.js → index.ts} +5 -0
  32. package/src/components/CheckboxField/CheckboxField.module.scss +7 -3
  33. package/src/components/CheckboxField/CheckboxField.tsx +81 -0
  34. package/src/components/CheckboxField/CheckboxField.types.ts +64 -0
  35. package/src/components/CheckboxField/README.md +92 -45
  36. package/src/components/CheckboxField/index.ts +5 -0
  37. package/src/components/FileInputField/FileInputField.module.scss +7 -3
  38. package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +43 -129
  39. package/src/components/FileInputField/FileInputField.types.ts +101 -0
  40. package/src/components/FileInputField/README.md +21 -4
  41. package/src/components/FileInputField/index.ts +6 -0
  42. package/src/components/FormLayout/FormLayout.module.scss +5 -7
  43. package/src/components/FormLayout/{FormLayout.jsx → FormLayout.tsx} +15 -50
  44. package/src/components/FormLayout/FormLayout.types.ts +55 -0
  45. package/src/components/FormLayout/FormLayoutContext.ts +4 -0
  46. package/src/components/FormLayout/FormLayoutCustomField.module.scss +7 -3
  47. package/src/components/FormLayout/{FormLayoutCustomField.jsx → FormLayoutCustomField.tsx} +12 -67
  48. package/src/components/FormLayout/FormLayoutCustomField.types.ts +60 -0
  49. package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
  50. package/src/components/FormLayout/README.md +6 -15
  51. package/src/components/FormLayout/index.ts +14 -0
  52. package/src/components/Grid/Grid.module.scss +1 -1
  53. package/src/components/Grid/Grid.tsx +50 -0
  54. package/src/components/Grid/Grid.types.ts +108 -0
  55. package/src/components/Grid/GridSpan.tsx +36 -0
  56. package/src/components/Grid/README.md +2 -2
  57. package/src/components/Grid/_helpers/generateResponsiveCustomProperties.ts +33 -0
  58. package/src/components/Grid/index.ts +9 -0
  59. package/src/components/InputGroup/InputGroup.module.scss +7 -3
  60. package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -95
  61. package/src/components/InputGroup/InputGroup.types.ts +80 -0
  62. package/src/components/InputGroup/InputGroupContext.ts +4 -0
  63. package/src/components/InputGroup/README.md +40 -8
  64. package/src/components/InputGroup/{index.js → index.ts} +4 -0
  65. package/src/components/Modal/Modal.tsx +172 -0
  66. package/src/components/Modal/Modal.types.ts +181 -0
  67. package/src/components/Modal/ModalBody.tsx +34 -0
  68. package/src/components/Modal/{ModalCloseButton.jsx → ModalCloseButton.tsx} +6 -19
  69. package/src/components/Modal/{ModalContent.jsx → ModalContent.tsx} +4 -15
  70. package/src/components/Modal/ModalFooter.tsx +27 -0
  71. package/src/components/Modal/ModalHeader.tsx +27 -0
  72. package/src/components/Modal/ModalTitle.tsx +29 -0
  73. package/src/components/Modal/README.md +9 -9
  74. package/src/components/Modal/_helpers/{dialogOnCancelHandler.js → dialogOnCancelHandler.ts} +11 -1
  75. package/src/components/Modal/_helpers/{dialogOnClickHandler.js → dialogOnClickHandler.ts} +13 -7
  76. package/src/components/Modal/_helpers/{dialogOnCloseHandler.js → dialogOnCloseHandler.ts} +11 -1
  77. package/src/components/Modal/_helpers/{dialogOnKeyDownHandler.js → dialogOnKeyDownHandler.ts} +19 -6
  78. package/src/components/Modal/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
  79. package/src/components/Modal/_helpers/getPositionClassName.ts +10 -0
  80. package/src/components/Modal/_helpers/getScrollingClassName.ts +14 -0
  81. package/src/components/Modal/_helpers/{getSizeClassName.js → getSizeClassName.ts} +4 -1
  82. package/src/components/Modal/_hooks/{useModalFocus.js → useModalFocus.ts} +9 -5
  83. package/src/components/Modal/_hooks/{useModalScrollPrevention.js → useModalScrollPrevention.ts} +4 -1
  84. package/src/components/Modal/{index.js → index.ts} +14 -0
  85. package/src/components/Paper/{Paper.jsx → Paper.tsx} +6 -26
  86. package/src/components/Paper/Paper.types.ts +19 -0
  87. package/src/components/Paper/README.md +3 -4
  88. package/src/components/Paper/index.ts +2 -0
  89. package/src/components/Popover/Popover.module.scss +1 -1
  90. package/src/components/Popover/Popover.tsx +61 -0
  91. package/src/components/Popover/Popover.types.ts +75 -0
  92. package/src/components/Popover/PopoverWrapper.tsx +27 -0
  93. package/src/components/Popover/README.md +34 -22
  94. package/src/components/Popover/_helpers/{cleanPlacementStyle.js → cleanPlacementStyle.ts} +4 -1
  95. package/src/components/Popover/_helpers/{getRootAlignmentClassName.js → getRootAlignmentClassName.ts} +4 -1
  96. package/src/components/Popover/_helpers/{getRootSideClassName.js → getRootSideClassName.ts} +4 -1
  97. package/src/components/Popover/index.ts +8 -0
  98. package/src/components/Radio/README.md +125 -48
  99. package/src/components/Radio/Radio.module.scss +7 -3
  100. package/src/components/Radio/Radio.tsx +116 -0
  101. package/src/components/Radio/Radio.types.ts +91 -0
  102. package/src/components/Radio/index.ts +5 -0
  103. package/src/components/ScrollView/README.md +1 -1
  104. package/src/components/ScrollView/ScrollView.module.scss +5 -0
  105. package/src/components/ScrollView/{ScrollView.jsx → ScrollView.tsx} +55 -166
  106. package/src/components/ScrollView/ScrollView.types.ts +121 -0
  107. package/src/components/ScrollView/_helpers/getElementsPositionDifference.ts +17 -0
  108. package/src/components/ScrollView/_hooks/{useLoadResizeHook.js → useLoadResizeHook.ts} +14 -3
  109. package/src/components/ScrollView/_hooks/{useScrollPositionHook.js → useScrollPositionHook.ts} +11 -4
  110. package/src/components/ScrollView/index.ts +6 -0
  111. package/src/components/SelectField/README.md +137 -51
  112. package/src/components/SelectField/SelectField.module.scss +7 -3
  113. package/src/components/SelectField/SelectField.tsx +139 -0
  114. package/src/components/SelectField/SelectField.types.ts +121 -0
  115. package/src/components/SelectField/_components/Option/Option.tsx +19 -0
  116. package/src/components/SelectField/_components/Option/Option.types.ts +21 -0
  117. package/src/components/SelectField/_components/Option/index.ts +2 -0
  118. package/src/components/SelectField/index.ts +7 -0
  119. package/src/components/Table/README.md +1 -1
  120. package/src/components/Table/{Table.jsx → Table.tsx} +4 -43
  121. package/src/components/Table/Table.types.ts +51 -0
  122. package/src/components/Table/_components/TableBodyCell/TableBodyCell.tsx +20 -0
  123. package/src/components/Table/_components/TableBodyCell/TableBodyCell.types.ts +20 -0
  124. package/src/components/Table/_components/TableBodyCell/index.ts +2 -0
  125. package/src/components/Table/_components/TableHeaderCell/{TableHeaderCell.jsx → TableHeaderCell.tsx} +3 -34
  126. package/src/components/Table/_components/TableHeaderCell/TableHeaderCell.types.ts +20 -0
  127. package/src/components/Table/_components/TableHeaderCell/index.ts +2 -0
  128. package/src/components/Table/index.ts +8 -0
  129. package/src/components/Tabs/README.md +2 -2
  130. package/src/components/Tabs/{Tabs.jsx → Tabs.tsx} +4 -20
  131. package/src/components/Tabs/Tabs.types.ts +19 -0
  132. package/src/components/Tabs/TabsItem.tsx +49 -0
  133. package/src/components/Tabs/TabsItem.types.ts +42 -0
  134. package/src/components/Tabs/index.ts +4 -0
  135. package/src/components/Text/README.md +1 -1
  136. package/src/components/Text/Text.module.scss +5 -7
  137. package/src/components/Text/Text.tsx +46 -0
  138. package/src/components/Text/Text.types.ts +31 -0
  139. package/src/components/Text/_helpers/getRootClampClassName.ts +13 -0
  140. package/src/components/Text/_helpers/getRootHyphensClassName.ts +14 -0
  141. package/src/components/Text/_helpers/getRootWordWrappingClassName.ts +14 -0
  142. package/src/components/Text/index.ts +6 -0
  143. package/src/components/TextArea/README.md +35 -14
  144. package/src/components/TextArea/TextArea.module.scss +7 -3
  145. package/src/components/TextArea/TextArea.tsx +95 -0
  146. package/src/components/TextArea/TextArea.types.ts +76 -0
  147. package/src/components/TextArea/index.ts +5 -0
  148. package/src/components/TextField/README.md +35 -13
  149. package/src/components/TextField/TextField.module.scss +7 -3
  150. package/src/components/TextField/TextField.tsx +112 -0
  151. package/src/components/TextField/TextField.types.ts +95 -0
  152. package/src/components/TextField/index.ts +6 -0
  153. package/src/components/TextLink/README.md +2 -2
  154. package/src/components/TextLink/{TextLink.jsx → TextLink.tsx} +4 -15
  155. package/src/components/TextLink/TextLink.types.ts +12 -0
  156. package/src/components/TextLink/index.ts +2 -0
  157. package/src/components/Toggle/README.md +92 -45
  158. package/src/components/Toggle/Toggle.module.scss +7 -3
  159. package/src/components/Toggle/Toggle.tsx +82 -0
  160. package/src/components/Toggle/Toggle.types.ts +59 -0
  161. package/src/components/Toggle/index.ts +5 -0
  162. package/src/components/Toolbar/README.md +3 -3
  163. package/src/components/Toolbar/Toolbar.tsx +41 -0
  164. package/src/components/Toolbar/Toolbar.types.ts +74 -0
  165. package/src/components/Toolbar/ToolbarGroup.tsx +38 -0
  166. package/src/components/Toolbar/{ToolbarItem.jsx → ToolbarItem.tsx} +5 -21
  167. package/src/components/Toolbar/_helpers/{getAlignClassName.js → getAlignClassName.ts} +8 -1
  168. package/src/components/Toolbar/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
  169. package/src/components/Toolbar/{index.js → index.ts} +7 -0
  170. package/src/components/_helpers/{getRootColorClassName.js → getRootColorClassName.ts} +7 -2
  171. package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +7 -2
  172. package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +7 -2
  173. package/src/components/_helpers/getRootStateClassName.ts +24 -0
  174. package/src/components/_helpers/resolveContextOrProp.ts +13 -0
  175. package/src/helpers/classNames/{classNames.js → classNames.ts} +2 -2
  176. package/src/helpers/isChildrenEmpty/isChildrenEmpty.ts +5 -0
  177. package/src/helpers/transferProps/transferProps.ts +50 -0
  178. package/src/helpers/transferProps/transferProps.types.ts +11 -0
  179. package/src/index.ts +211 -0
  180. package/src/providers/globalProps/GlobalProps.types.ts +30 -0
  181. package/src/providers/globalProps/GlobalPropsContext.ts +6 -0
  182. package/src/providers/globalProps/{GlobalPropsProvider.jsx → GlobalPropsProvider.tsx} +8 -15
  183. package/src/providers/globalProps/{index.js → index.ts} +4 -0
  184. package/src/providers/globalProps/withGlobalProps.tsx +36 -0
  185. package/src/providers/translations/Translations.types.ts +26 -0
  186. package/src/providers/translations/TranslationsContext.ts +7 -0
  187. package/src/providers/translations/{TranslationsProvider.jsx → TranslationsProvider.tsx} +8 -15
  188. package/src/providers/translations/{index.js → index.ts} +5 -0
  189. package/src/styles/settings/_form-fields.scss +2 -1
  190. package/src/styles/theme/_form-fields.scss +16 -11
  191. package/src/styles/theme-constants/_colors.scss +21 -0
  192. package/src/styles/tools/_accessibility.scss +2 -2
  193. package/src/styles/tools/form-fields/_box-field-layout.scss +5 -8
  194. package/src/styles/tools/form-fields/_inline-field-elements.scss +0 -7
  195. package/src/styles/tools/form-fields/_inline-field-layout.scss +0 -8
  196. package/src/styles/tools/form-fields/_variants.scss +7 -7
  197. package/src/theme.scss +37 -12
  198. package/src/translations/{en.js → en.ts} +3 -1
  199. package/src/types/breakpoints.ts +1 -0
  200. package/src/types/colors.ts +7 -0
  201. package/src/types/index.ts +13 -0
  202. package/src/types/labelPositions.ts +1 -0
  203. package/src/types/layouts.ts +1 -0
  204. package/src/types/modules.d.ts +16 -0
  205. package/src/types/priorities.ts +1 -0
  206. package/src/types/sizes.ts +1 -0
  207. package/src/types/states.ts +1 -0
  208. package/src/types/styles.ts +4 -0
  209. package/src/utils/mergeDeep.ts +34 -0
  210. package/src/utils/mergeDeep.types.ts +4 -0
  211. package/.claude/agents/code-reviewer.md +0 -122
  212. package/.claude/rules/code.md +0 -22
  213. package/.claude/rules/docs.md +0 -35
  214. package/.claude/rules/frontend.md +0 -72
  215. package/.claude/rules/git.md +0 -13
  216. package/.claude/rules/safety-guards.md +0 -9
  217. package/.claude/rules/styling.md +0 -32
  218. package/.claude/rules/testing.md +0 -59
  219. package/.claude/settings.json +0 -32
  220. package/.claude/skills/commit/SKILL.md +0 -54
  221. package/.devcontainer/devcontainer.json +0 -23
  222. package/.eslintrc-ts +0 -40
  223. package/.mcp.json +0 -8
  224. package/.nvmrc +0 -1
  225. package/CLAUDE.md +0 -82
  226. package/docker-compose.base.yml +0 -93
  227. package/docker-compose.yml.dist +0 -41
  228. package/jest.config-ts.js +0 -34
  229. package/opencode.json +0 -10
  230. package/playwright-ct.config.ts +0 -68
  231. package/scripts/auto-start-mkdocs.sh +0 -5
  232. package/scripts/auto-start-node.sh +0 -33
  233. package/scripts/mcps/chrome-host/README.md +0 -118
  234. package/scripts/mcps/chrome-host/cdp_proxy.py +0 -90
  235. package/scripts/mcps/chrome-host/mcp-entry.sh +0 -33
  236. package/scripts/mcps/chrome-host/mcp-launch.sh +0 -36
  237. package/scripts/mcps/chrome-host/mcp-setup.sh +0 -70
  238. package/scripts/mcps/chrome-host/start-host-chrome.sh +0 -267
  239. package/setup.sh +0 -107
  240. package/src/CNAME +0 -1
  241. package/src/components/Alert/index.js +0 -1
  242. package/src/components/Badge/Badge.jsx +0 -51
  243. package/src/components/Badge/index.js +0 -1
  244. package/src/components/Button/Button.jsx +0 -203
  245. package/src/components/Button/helpers/getRootPriorityClassName.js +0 -15
  246. package/src/components/Button/index.js +0 -1
  247. package/src/components/ButtonGroup/ButtonGroupContext.js +0 -3
  248. package/src/components/Card/Card.jsx +0 -67
  249. package/src/components/CheckboxField/CheckboxField.jsx +0 -144
  250. package/src/components/CheckboxField/index.js +0 -1
  251. package/src/components/FileInputField/index.js +0 -1
  252. package/src/components/FormLayout/FormLayoutContext.js +0 -3
  253. package/src/components/FormLayout/FormLayoutCustomFieldContext.js +0 -3
  254. package/src/components/FormLayout/index.js +0 -4
  255. package/src/components/Grid/Grid.jsx +0 -225
  256. package/src/components/Grid/GridSpan.jsx +0 -88
  257. package/src/components/Grid/_helpers/generateResponsiveCustomProperties.js +0 -22
  258. package/src/components/Grid/index.js +0 -2
  259. package/src/components/InputGroup/InputGroupContext.js +0 -3
  260. package/src/components/Modal/Modal.jsx +0 -262
  261. package/src/components/Modal/ModalBody.jsx +0 -60
  262. package/src/components/Modal/ModalFooter.jsx +0 -42
  263. package/src/components/Modal/ModalHeader.jsx +0 -42
  264. package/src/components/Modal/ModalTitle.jsx +0 -42
  265. package/src/components/Modal/_helpers/getPositionClassName.js +0 -7
  266. package/src/components/Modal/_helpers/getScrollingClassName.js +0 -11
  267. package/src/components/Paper/index.js +0 -1
  268. package/src/components/Popover/Popover.jsx +0 -124
  269. package/src/components/Popover/PopoverWrapper.jsx +0 -38
  270. package/src/components/Popover/index.js +0 -2
  271. package/src/components/Radio/Radio.jsx +0 -212
  272. package/src/components/Radio/index.js +0 -1
  273. package/src/components/ScrollView/_helpers/getElementsPositionDifference.js +0 -11
  274. package/src/components/ScrollView/index.js +0 -1
  275. package/src/components/SelectField/SelectField.jsx +0 -272
  276. package/src/components/SelectField/_components/Option/Option.jsx +0 -46
  277. package/src/components/SelectField/_components/Option/index.js +0 -1
  278. package/src/components/SelectField/index.js +0 -1
  279. package/src/components/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -46
  280. package/src/components/Table/_components/TableBodyCell/index.js +0 -1
  281. package/src/components/Table/_components/TableHeaderCell/index.js +0 -1
  282. package/src/components/Table/index.js +0 -1
  283. package/src/components/Tabs/TabsItem.jsx +0 -91
  284. package/src/components/Tabs/index.js +0 -2
  285. package/src/components/Text/Text.jsx +0 -76
  286. package/src/components/Text/_helpers/getRootClampClassName.js +0 -11
  287. package/src/components/Text/_helpers/getRootHyphensClassName.js +0 -11
  288. package/src/components/Text/_helpers/getRootWordWrappingClassName.js +0 -11
  289. package/src/components/Text/index.js +0 -1
  290. package/src/components/TextArea/TextArea.jsx +0 -174
  291. package/src/components/TextArea/index.js +0 -1
  292. package/src/components/TextField/TextField.jsx +0 -208
  293. package/src/components/TextField/index.js +0 -1
  294. package/src/components/TextLink/index.js +0 -1
  295. package/src/components/Toggle/Toggle.jsx +0 -144
  296. package/src/components/Toggle/index.js +0 -1
  297. package/src/components/Toolbar/Toolbar.jsx +0 -76
  298. package/src/components/Toolbar/ToolbarGroup.jsx +0 -64
  299. package/src/components/_helpers/getRootValidationStateClassName.js +0 -15
  300. package/src/components/_helpers/resolveContextOrProp.js +0 -10
  301. package/src/helpers/isChildrenEmpty/isChildrenEmpty.js +0 -3
  302. package/src/helpers/transferProps/transferProps.js +0 -38
  303. package/src/index.js +0 -67
  304. package/src/providers/globalProps/GlobalPropsContext.jsx +0 -5
  305. package/src/providers/globalProps/withGlobalProps.jsx +0 -38
  306. package/src/providers/translations/TranslationsContext.jsx +0 -6
  307. package/src/utils/mergeDeep.js +0 -28
  308. package/tsconfig.json +0 -27
  309. /package/src/helpers/classNames/{index.js → index.ts} +0 -0
  310. /package/src/helpers/isChildrenEmpty/{index.js → index.ts} +0 -0
  311. /package/src/helpers/transferProps/{index.js → index.ts} +0 -0
@@ -0,0 +1,181 @@
1
+ import type {
2
+ ButtonHTMLAttributes,
3
+ DialogHTMLAttributes,
4
+ HTMLAttributes,
5
+ ReactNode,
6
+ Ref,
7
+ RefObject,
8
+ } from 'react';
9
+ import type {
10
+ FeedbackColor,
11
+ Size,
12
+ } from '../../types';
13
+
14
+ export type ModalJustify = 'start' | 'center' | 'end' | 'space-between' | 'stretch';
15
+
16
+ export type ModalPosition = 'top' | 'center';
17
+
18
+ export type ModalScrolling = 'auto' | 'custom' | 'none';
19
+
20
+ export type ModalScrollPrevention = 'off' | HTMLElement | {
21
+ reset: () => void;
22
+ start: () => void;
23
+ };
24
+
25
+ export type ModalSize = Size | 'fullscreen' | 'auto';
26
+
27
+ /**
28
+ * Props of the `Modal` component.
29
+ */
30
+ export type ModalProps = Omit<DialogHTMLAttributes<HTMLDialogElement>, 'color'> & {
31
+ /**
32
+ * If `true`, the `Modal` can be closed by clicking on the backdrop.
33
+ */
34
+ allowCloseOnBackdropClick?: boolean;
35
+ /**
36
+ * If `true`, the `Modal` can be closed by pressing the Escape key.
37
+ */
38
+ allowCloseOnEscapeKey?: boolean;
39
+ /**
40
+ * If `true`, the `Modal` can be submitted by pressing the Enter key.
41
+ */
42
+ allowPrimaryActionOnEnterKey?: boolean;
43
+ /**
44
+ * If `true`, focus the first input element in the `Modal`, or primary button (referenced by the `primaryButtonRef`
45
+ * prop), or other focusable element when the `Modal` is opened. If there are none or `autoFocus` is set to `false`,
46
+ * focus the Modal itself.
47
+ */
48
+ autoFocus?: boolean;
49
+ /**
50
+ * Nested elements. Supported types are:
51
+ *
52
+ * * `ModalHeader`
53
+ * * `ModalBody`
54
+ * * `ModalFooter`
55
+ *
56
+ * At least `ModalBody` is required.
57
+ */
58
+ children?: ReactNode;
59
+ /**
60
+ * Reference to close button element. It is used to close modal when Escape key is pressed
61
+ * or the backdrop is clicked.
62
+ */
63
+ closeButtonRef?: RefObject<HTMLButtonElement | null>;
64
+ /**
65
+ * Color to clarify importance and meaning of the modal. Implements
66
+ * [Feedback color collection](/docs/foundation/collections#colors).
67
+ */
68
+ color?: FeedbackColor;
69
+ /**
70
+ * Reference to dialog element
71
+ */
72
+ dialogRef?: Ref<HTMLDialogElement>;
73
+ /**
74
+ * If set, modal is rendered in the React Portal with that ID.
75
+ */
76
+ portalId?: string;
77
+ /**
78
+ * Vertical position of the modal inside browser window.
79
+ */
80
+ position?: ModalPosition;
81
+ /**
82
+ * Mode in which Modal prevents scroll of elements bellow:
83
+ * * `off` - Modal does not prevent any scroll
84
+ * * [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) - Modal prevents scroll on this HTML element
85
+ * * object
86
+ * * `reset` - method called on Modal's unmount to reset scroll prevention
87
+ * * `start` - method called on Modal's mount to custom scroll prevention
88
+ */
89
+ preventScrollUnderneath?: ModalScrollPrevention;
90
+ /**
91
+ * Reference to primary button element. It is used to submit modal when Enter key is pressed and as fallback
92
+ * when `autoFocus` functionality does not find any input element to be focused.
93
+ */
94
+ primaryButtonRef?: RefObject<HTMLButtonElement | null>;
95
+ /**
96
+ * Size of the modal.
97
+ */
98
+ size?: ModalSize;
99
+ };
100
+
101
+ export type ModalBodyProps = HTMLAttributes<HTMLDivElement> & {
102
+ /**
103
+ * Nested elements. Supported types are:
104
+ *
105
+ * * `ModalContent`
106
+ * * `ScrollView` (`scrolling: 'custom'` must be set)
107
+ *
108
+ * You can also provide a custom component responsible for scrolling and displaying content correctly.
109
+ * At most one nested element is allowed. If none are provided nothing is rendered.
110
+ */
111
+ children?: ReactNode;
112
+ /**
113
+ * Scrolling mode:
114
+ *
115
+ * - `auto`: scrolling is enabled on ModalBody.
116
+ * - `custom`: use if providing a custom scrolling component, e.g. an instance of `ScrollView`.
117
+ * - `none`: scrolling is disabled on ModalBody and the entire Modal is scrollable instead.
118
+ */
119
+ scrolling?: ModalScrolling;
120
+ };
121
+
122
+ export type ModalCloseButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'title'> & {
123
+ /**
124
+ * If `true`, close button will be disabled.
125
+ */
126
+ disabled?: boolean;
127
+ };
128
+
129
+ export type ModalContentProps = HTMLAttributes<HTMLDivElement> & {
130
+ /**
131
+ * Content of the modal.
132
+ */
133
+ children?: ReactNode;
134
+ };
135
+
136
+ export type ModalFooterProps = HTMLAttributes<HTMLDivElement> & {
137
+ /**
138
+ * Content of the footer (preferably nested `Button` elements).
139
+ */
140
+ children: ReactNode;
141
+ /**
142
+ * Horizontal alignment (distribution) of individual buttons.
143
+ */
144
+ justify?: ModalJustify;
145
+ };
146
+
147
+ export type ModalHeaderProps = HTMLAttributes<HTMLDivElement> & {
148
+ /**
149
+ * Content of the header (preferably ModalTitle and ModalCloseButton).
150
+ */
151
+ children: ReactNode;
152
+ /**
153
+ * Horizontal alignment (distribution) of individual buttons.
154
+ */
155
+ justify?: ModalJustify;
156
+ };
157
+
158
+ export type ModalTitleProps = HTMLAttributes<HTMLHeadingElement> & {
159
+ /**
160
+ * Content of the header (preferably ModalTitle and ModalCloseButton).
161
+ */
162
+ children: ReactNode;
163
+ /**
164
+ * Optional heading level. Preferably `1` or `2` should be used, see
165
+ * [W3C recommendation](https://github.com/w3c/aria-practices/issues/551#issuecomment-365134527).
166
+ */
167
+ level?: number;
168
+ };
169
+
170
+ /**
171
+ * Dialog event handlers wired by `Modal`.
172
+ */
173
+ export type ModalEvents = Pick<
174
+ DialogHTMLAttributes<HTMLDialogElement>,
175
+ 'onCancel' | 'onClick' | 'onClose' | 'onKeyDown' | 'onMouseDown'
176
+ >;
177
+
178
+ /**
179
+ * Heading element rendered by `ModalTitle` according to its `level`.
180
+ */
181
+ export type ModalTitleHeadingTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { withGlobalProps } from '../../providers/globalProps';
3
+ import { classNames } from '../../helpers/classNames/classNames';
4
+ import { transferProps } from '../../helpers/transferProps';
5
+ import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
6
+ import { getScrollingClassName } from './_helpers/getScrollingClassName';
7
+ import styles from './ModalBody.module.scss';
8
+ import type { ModalBodyProps } from './Modal.types';
9
+
10
+ export const ModalBody: React.FunctionComponent<ModalBodyProps> = ({
11
+ children,
12
+ scrolling = 'auto',
13
+ ...restProps
14
+ }: ModalBodyProps) => {
15
+ if (isChildrenEmpty(children)) {
16
+ return null;
17
+ }
18
+
19
+ return (
20
+ <div
21
+ {...transferProps(restProps)}
22
+ className={classNames(
23
+ styles.root,
24
+ getScrollingClassName(styles, scrolling),
25
+ )}
26
+ >
27
+ {children}
28
+ </div>
29
+ );
30
+ };
31
+
32
+ export const ModalBodyWithGlobalProps = withGlobalProps<ModalBodyProps, never>(ModalBody, 'ModalBody');
33
+
34
+ export default ModalBodyWithGlobalProps;
@@ -1,16 +1,14 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, { useContext } from 'react';
3
2
  import { TranslationsContext } from '../../providers/translations';
4
3
  import { withGlobalProps } from '../../providers/globalProps';
5
4
  import { transferProps } from '../../helpers/transferProps';
6
5
  import styles from './ModalCloseButton.module.scss';
6
+ import type { ModalCloseButtonProps } from './Modal.types';
7
7
 
8
- export const ModalCloseButton = React.forwardRef((props, ref) => {
9
- const {
10
- disabled,
11
- ...restProps
12
- } = props;
13
-
8
+ export const ModalCloseButton = React.forwardRef<HTMLButtonElement, ModalCloseButtonProps>(({
9
+ disabled = false,
10
+ ...restProps
11
+ }, ref) => {
14
12
  const translations = useContext(TranslationsContext);
15
13
 
16
14
  return (
@@ -27,17 +25,6 @@ export const ModalCloseButton = React.forwardRef((props, ref) => {
27
25
  );
28
26
  });
29
27
 
30
- ModalCloseButton.defaultProps = {
31
- disabled: false,
32
- };
33
-
34
- ModalCloseButton.propTypes = {
35
- /**
36
- * If `true`, close button will be disabled.
37
- */
38
- disabled: PropTypes.bool,
39
- };
40
-
41
- export const ModalCloseButtonWithGlobalProps = withGlobalProps(ModalCloseButton, 'ModalCloseButton');
28
+ export const ModalCloseButtonWithGlobalProps = withGlobalProps<ModalCloseButtonProps, HTMLButtonElement>(ModalCloseButton, 'ModalCloseButton');
42
29
 
43
30
  export default ModalCloseButtonWithGlobalProps;
@@ -1,14 +1,14 @@
1
- import PropTypes from 'prop-types';
2
1
  import React from 'react';
3
2
  import { withGlobalProps } from '../../providers/globalProps';
4
3
  import { transferProps } from '../../helpers/transferProps';
5
4
  import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
6
5
  import styles from './ModalContent.module.scss';
6
+ import type { ModalContentProps } from './Modal.types';
7
7
 
8
- export const ModalContent = ({
8
+ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
9
9
  children,
10
10
  ...restProps
11
- }) => {
11
+ }: ModalContentProps) => {
12
12
  if (isChildrenEmpty(children)) {
13
13
  return null;
14
14
  }
@@ -23,17 +23,6 @@ export const ModalContent = ({
23
23
  );
24
24
  };
25
25
 
26
- ModalContent.defaultProps = {
27
- children: undefined,
28
- };
29
-
30
- ModalContent.propTypes = {
31
- /**
32
- * Content of the modal.
33
- */
34
- children: PropTypes.node,
35
- };
36
-
37
- export const ModalContentWithGlobalProps = withGlobalProps(ModalContent, 'ModalContent');
26
+ export const ModalContentWithGlobalProps = withGlobalProps<ModalContentProps, never>(ModalContent, 'ModalContent');
38
27
 
39
28
  export default ModalContentWithGlobalProps;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { withGlobalProps } from '../../providers/globalProps';
3
+ import { classNames } from '../../helpers/classNames/classNames';
4
+ import { transferProps } from '../../helpers/transferProps';
5
+ import { getJustifyClassName } from './_helpers/getJustifyClassName';
6
+ import styles from './ModalFooter.module.scss';
7
+ import type { ModalFooterProps } from './Modal.types';
8
+
9
+ export const ModalFooter: React.FunctionComponent<ModalFooterProps> = ({
10
+ children,
11
+ justify = 'center',
12
+ ...restProps
13
+ }: ModalFooterProps) => (
14
+ <div
15
+ {...transferProps(restProps)}
16
+ className={classNames(
17
+ styles.root,
18
+ getJustifyClassName(styles, justify),
19
+ )}
20
+ >
21
+ {children}
22
+ </div>
23
+ );
24
+
25
+ export const ModalFooterWithGlobalProps = withGlobalProps<ModalFooterProps, never>(ModalFooter, 'ModalFooter');
26
+
27
+ export default ModalFooterWithGlobalProps;
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { withGlobalProps } from '../../providers/globalProps';
3
+ import { classNames } from '../../helpers/classNames/classNames';
4
+ import { transferProps } from '../../helpers/transferProps';
5
+ import { getJustifyClassName } from './_helpers/getJustifyClassName';
6
+ import styles from './ModalHeader.module.scss';
7
+ import type { ModalHeaderProps } from './Modal.types';
8
+
9
+ export const ModalHeader: React.FunctionComponent<ModalHeaderProps> = ({
10
+ children,
11
+ justify = 'space-between',
12
+ ...restProps
13
+ }: ModalHeaderProps) => (
14
+ <div
15
+ {...transferProps(restProps)}
16
+ className={classNames(
17
+ styles.root,
18
+ getJustifyClassName(styles, justify),
19
+ )}
20
+ >
21
+ {children}
22
+ </div>
23
+ );
24
+
25
+ export const ModalHeaderWithGlobalProps = withGlobalProps<ModalHeaderProps, never>(ModalHeader, 'ModalHeader');
26
+
27
+ export default ModalHeaderWithGlobalProps;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { withGlobalProps } from '../../providers/globalProps';
3
+ import { transferProps } from '../../helpers/transferProps';
4
+ import styles from './ModalTitle.module.scss';
5
+ import type {
6
+ ModalTitleHeadingTag,
7
+ ModalTitleProps,
8
+ } from './Modal.types';
9
+
10
+ export const ModalTitle: React.FunctionComponent<ModalTitleProps> = ({
11
+ children,
12
+ level = 2,
13
+ ...restProps
14
+ }: ModalTitleProps) => {
15
+ const HeadingTag = `h${level}` as ModalTitleHeadingTag;
16
+
17
+ return (
18
+ <HeadingTag
19
+ {...transferProps(restProps)}
20
+ className={styles.root}
21
+ >
22
+ {children}
23
+ </HeadingTag>
24
+ );
25
+ };
26
+
27
+ export const ModalTitleWithGlobalProps = withGlobalProps<ModalTitleProps, never>(ModalTitle, 'ModalTitle');
28
+
29
+ export default ModalTitleWithGlobalProps;
@@ -97,8 +97,8 @@ See [API](#api) for all available options.
97
97
  modal behavior and shall be **removed from DOM when closed**.
98
98
 
99
99
  - Modal **automatically focuses the first non-disabled form field** by default.
100
- When no field is found then the primary button (in the footer) is focused. To turn
101
- this feature off, set the `autofocus` prop to `false`.
100
+ When no field is found then the primary button (in the footer) is focused.
101
+ To turn this feature off, set the `autofocus` prop to `false`.
102
102
 
103
103
  - Modal **submits the form when the user presses the `Enter` key** . A click is
104
104
  programmatically triggered on the primary button in this case. To turn this
@@ -1240,31 +1240,31 @@ accessibility.
1240
1240
 
1241
1241
  ## API
1242
1242
 
1243
- <docoff-react-props src="/components/Modal/Modal.jsx"></docoff-react-props>
1243
+ <docoff-react-props src="/components/Modal/Modal.tsx" name="Modal"></docoff-react-props>
1244
1244
 
1245
1245
  ### ModalHeader
1246
1246
 
1247
- <docoff-react-props src="/components/Modal/ModalHeader.jsx"></docoff-react-props>
1247
+ <docoff-react-props src="/components/Modal/ModalHeader.tsx" name="ModalHeader"></docoff-react-props>
1248
1248
 
1249
1249
  ### ModalTitle
1250
1250
 
1251
- <docoff-react-props src="/components/Modal/ModalTitle.jsx"></docoff-react-props>
1251
+ <docoff-react-props src="/components/Modal/ModalTitle.tsx" name="ModalTitle"></docoff-react-props>
1252
1252
 
1253
1253
  ### ModalCloseButton
1254
1254
 
1255
- <docoff-react-props src="/components/Modal/ModalCloseButton.jsx"></docoff-react-props>
1255
+ <docoff-react-props src="/components/Modal/ModalCloseButton.tsx" name="ModalCloseButton"></docoff-react-props>
1256
1256
 
1257
1257
  ### ModalBody
1258
1258
 
1259
- <docoff-react-props src="/components/Modal/ModalBody.jsx"></docoff-react-props>
1259
+ <docoff-react-props src="/components/Modal/ModalBody.tsx" name="ModalBody"></docoff-react-props>
1260
1260
 
1261
1261
  ### ModalContent
1262
1262
 
1263
- <docoff-react-props src="/components/Modal/ModalContent.jsx"></docoff-react-props>
1263
+ <docoff-react-props src="/components/Modal/ModalContent.tsx" name="ModalContent"></docoff-react-props>
1264
1264
 
1265
1265
  ### ModalFooter
1266
1266
 
1267
- <docoff-react-props src="/components/Modal/ModalFooter.jsx"></docoff-react-props>
1267
+ <docoff-react-props src="/components/Modal/ModalFooter.tsx" name="ModalFooter"></docoff-react-props>
1268
1268
 
1269
1269
  ## Theming
1270
1270
 
@@ -1,3 +1,9 @@
1
+ import type {
2
+ ReactEventHandler,
3
+ RefObject,
4
+ SyntheticEvent,
5
+ } from 'react';
6
+
1
7
  // Disable coverage for the following function
2
8
  /* istanbul ignore next */
3
9
 
@@ -12,7 +18,11 @@
12
18
  * @param closeButtonRef
13
19
  * @param onCancelHandler
14
20
  */
15
- export const dialogOnCancelHandler = (e, closeButtonRef, onCancelHandler = undefined) => {
21
+ export const dialogOnCancelHandler = (
22
+ e: SyntheticEvent<HTMLDialogElement>,
23
+ closeButtonRef: RefObject<HTMLButtonElement | null> | undefined,
24
+ onCancelHandler: ReactEventHandler<HTMLDialogElement> | undefined = undefined,
25
+ ) => {
16
26
  // Prevent the default behaviour of the event as we want to close dialog manually.
17
27
  e.preventDefault();
18
28
 
@@ -1,3 +1,8 @@
1
+ import type {
2
+ MouseEvent,
3
+ RefObject,
4
+ } from 'react';
5
+
1
6
  // Disable coverage for the following function
2
7
  /* istanbul ignore next */
3
8
 
@@ -11,13 +16,14 @@
11
16
  * @param closeButtonRef
12
17
  * @param dialogRef
13
18
  * @param allowCloseOnBackdropClick
19
+ * @param mouseDownTarget
14
20
  */
15
21
  export const dialogOnClickHandler = (
16
- e,
17
- closeButtonRef,
18
- dialogRef,
19
- allowCloseOnBackdropClick,
20
- mouseDownTarget,
22
+ e: MouseEvent<HTMLDialogElement>,
23
+ closeButtonRef: RefObject<HTMLButtonElement | null> | undefined,
24
+ dialogRef: RefObject<HTMLDialogElement | null>,
25
+ allowCloseOnBackdropClick: boolean,
26
+ mouseDownTarget: EventTarget | null,
21
27
  ) => {
22
28
  // If it is not allowed to close modal on backdrop click, do nothing.
23
29
  if (!allowCloseOnBackdropClick) {
@@ -32,8 +38,8 @@ export const dialogOnClickHandler = (
32
38
  // Detection of the click on the backdrop is based on the following conditions:
33
39
  // 1. The click target is the dialog itself. This prevents detection of clicks on the dialog's children.
34
40
  // 2. The click is outside the dialog's boundaries.
35
- const dialogRect = dialogRef.current.getBoundingClientRect();
36
- const isClickedOnBackdrop = dialogRef.current === e.target && (
41
+ const dialogRect = dialogRef.current?.getBoundingClientRect();
42
+ const isClickedOnBackdrop = dialogRect !== undefined && dialogRef.current === e.target && (
37
43
  e.clientX < dialogRect.left
38
44
  || e.clientX > dialogRect.right
39
45
  || e.clientY < dialogRect.top
@@ -1,3 +1,9 @@
1
+ import type {
2
+ ReactEventHandler,
3
+ RefObject,
4
+ SyntheticEvent,
5
+ } from 'react';
6
+
1
7
  // Disable coverage for the following function
2
8
  /* istanbul ignore next */
3
9
 
@@ -12,7 +18,11 @@
12
18
  * @param closeButtonRef
13
19
  * @param onCloseHandler
14
20
  */
15
- export const dialogOnCloseHandler = (e, closeButtonRef, onCloseHandler = undefined) => {
21
+ export const dialogOnCloseHandler = (
22
+ e: SyntheticEvent<HTMLDialogElement>,
23
+ closeButtonRef: RefObject<HTMLButtonElement | null> | undefined,
24
+ onCloseHandler: ReactEventHandler<HTMLDialogElement> | undefined = undefined,
25
+ ) => {
16
26
  // Prevent the default behaviour of the event as we want to close dialog manually.
17
27
  e.preventDefault();
18
28
 
@@ -1,3 +1,16 @@
1
+ import type {
2
+ KeyboardEvent,
3
+ RefObject,
4
+ } from 'react';
5
+
6
+ // Declared locally so that consumers compiling the sources directly do not need `@types/node`.
7
+ // Bundlers replace `process.env.NODE_ENV` at build time.
8
+ declare const process: {
9
+ env: {
10
+ NODE_ENV?: string;
11
+ };
12
+ };
13
+
1
14
  // Disable coverage for the following function
2
15
  /* istanbul ignore next */
3
16
 
@@ -19,11 +32,11 @@
19
32
  * @param allowPrimaryActionOnEnterKey
20
33
  */
21
34
  export const dialogOnKeyDownHandler = (
22
- e,
23
- closeButtonRef,
24
- primaryButtonRef,
25
- allowCloseOnEscapeKey,
26
- allowPrimaryActionOnEnterKey,
35
+ e: KeyboardEvent<HTMLDialogElement>,
36
+ closeButtonRef: RefObject<HTMLButtonElement | null> | undefined,
37
+ primaryButtonRef: RefObject<HTMLButtonElement | null> | undefined,
38
+ allowCloseOnEscapeKey: boolean,
39
+ allowPrimaryActionOnEnterKey: boolean,
27
40
  ) => {
28
41
  if (e.key === 'Escape') {
29
42
  // Prevent closing the modal using the Escape key when one of the following conditions is met:
@@ -55,7 +68,7 @@ export const dialogOnKeyDownHandler = (
55
68
  && primaryButtonRef?.current != null
56
69
  && primaryButtonRef?.current?.disabled === false
57
70
  && allowPrimaryActionOnEnterKey
58
- && ['INPUT', 'SELECT'].includes(e.target.nodeName)
71
+ && ['INPUT', 'SELECT'].includes((e.target as HTMLElement).nodeName)
59
72
  ) {
60
73
  primaryButtonRef.current.click();
61
74
  }
@@ -1,4 +1,7 @@
1
- export const getJustifyClassName = (value, styles) => {
1
+ import type { CssModuleClasses } from '../../../types';
2
+ import type { ModalJustify } from '../Modal.types';
3
+
4
+ export const getJustifyClassName = (styles: CssModuleClasses, value?: ModalJustify) => {
2
5
  if (value === 'start') {
3
6
  return styles.isRootJustifiedToStart;
4
7
  }
@@ -0,0 +1,10 @@
1
+ import type { CssModuleClasses } from '../../../types';
2
+ import type { ModalPosition } from '../Modal.types';
3
+
4
+ export const getPositionClassName = (styles: CssModuleClasses, modalPosition?: ModalPosition) => {
5
+ if (modalPosition === 'top') {
6
+ return styles.isRootPositionTop;
7
+ }
8
+
9
+ return undefined;
10
+ };
@@ -0,0 +1,14 @@
1
+ import type { CssModuleClasses } from '../../../types';
2
+ import type { ModalScrolling } from '../Modal.types';
3
+
4
+ export const getScrollingClassName = (styles: CssModuleClasses, type?: ModalScrolling) => {
5
+ if (type === 'auto') {
6
+ return styles.isRootScrollingAuto;
7
+ }
8
+
9
+ if (type === 'custom') {
10
+ return styles.isRootScrollingCustom;
11
+ }
12
+
13
+ return undefined;
14
+ };
@@ -1,4 +1,7 @@
1
- export const getSizeClassName = (modalSize, styles) => {
1
+ import type { CssModuleClasses } from '../../../types';
2
+ import type { ModalSize } from '../Modal.types';
3
+
4
+ export const getSizeClassName = (styles: CssModuleClasses, modalSize?: ModalSize) => {
2
5
  if (modalSize === 'small') {
3
6
  return styles.isRootSizeSmall;
4
7
  }
@@ -1,9 +1,10 @@
1
1
  import { useEffect } from 'react';
2
+ import type { RefObject } from 'react';
2
3
 
3
4
  export const useModalFocus = (
4
- autoFocus,
5
- dialogRef,
6
- primaryButtonRef,
5
+ autoFocus: boolean,
6
+ dialogRef: RefObject<HTMLDialogElement | null>,
7
+ primaryButtonRef: RefObject<HTMLButtonElement | null> | undefined,
7
8
  ) => {
8
9
  useEffect(
9
10
  () => {
@@ -21,7 +22,9 @@ export const useModalFocus = (
21
22
  }
22
23
 
23
24
  const childrenFocusableElements = Array.from(
24
- dialogElement.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),
25
+ dialogElement.querySelectorAll<HTMLElement>(
26
+ 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',
27
+ ),
25
28
  );
26
29
 
27
30
  const firstFocusableElement = childrenFocusableElements[0];
@@ -33,7 +36,8 @@ export const useModalFocus = (
33
36
  }
34
37
 
35
38
  const firstFormFieldEl = childrenFocusableElements.find(
36
- (element) => ['INPUT', 'TEXTAREA', 'SELECT'].includes(element.nodeName) && !element.disabled,
39
+ (element) => ['INPUT', 'TEXTAREA', 'SELECT'].includes(element.nodeName)
40
+ && !(element as HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement).disabled,
37
41
  );
38
42
 
39
43
  if (firstFormFieldEl) {
@@ -1,6 +1,7 @@
1
1
  import { useLayoutEffect } from 'react';
2
+ import type { ModalScrollPrevention } from '../Modal.types';
2
3
 
3
- export const useModalScrollPrevention = (preventScrollUnderneath) => {
4
+ export const useModalScrollPrevention = (preventScrollUnderneath: ModalScrollPrevention) => {
4
5
  useLayoutEffect(
5
6
  () => {
6
7
  if (preventScrollUnderneath === 'off') {
@@ -14,6 +15,8 @@ export const useModalScrollPrevention = (preventScrollUnderneath) => {
14
15
  const prevOverflow = scrollableElement.style.overflow;
15
16
  const prevPaddingRight = scrollableElement.style.paddingRight;
16
17
 
18
+ // The element is a DOM node owned by the consumer, mutating its styles is the purpose of this hook.
19
+ // eslint-disable-next-line react-hooks/immutability
17
20
  scrollableElement.style.overflow = 'hidden';
18
21
 
19
22
  if (Number.isNaN(parseInt(prevPaddingRight, 10))) {