@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
@@ -263,13 +263,13 @@ accessibility.
263
263
 
264
264
  ## API
265
265
 
266
- <docoff-react-props src="/components/Grid/Grid.jsx"></docoff-react-props>
266
+ <docoff-react-props src="/components/Grid/Grid.tsx" name="Grid"></docoff-react-props>
267
267
 
268
268
  ### GridSpan API
269
269
 
270
270
  Wrapper for content that should span multiple rows or columns.
271
271
 
272
- <docoff-react-props src="/components/Grid/GridSpan.jsx"></docoff-react-props>
272
+ <docoff-react-props src="/components/Grid/GridSpan.tsx" name="GridSpan"></docoff-react-props>
273
273
 
274
274
  [grid-layout]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
275
275
  [grid-template-columns]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
@@ -0,0 +1,33 @@
1
+ import type { Breakpoint } from '../../../types';
2
+ import type {
3
+ GridResponsivePropertyValue,
4
+ GridResponsiveValue,
5
+ } from '../Grid.types';
6
+
7
+ const prepareValueByType = (value: GridResponsivePropertyValue, type: 'spacing' | null) => {
8
+ if (type === 'spacing') {
9
+ return `var(--rui-dimension-space-${value})`;
10
+ }
11
+
12
+ return value;
13
+ };
14
+
15
+ // Returns `null` on purpose: the result is spread into `style`, where `null` is a valid empty value.
16
+ export const generateResponsiveCustomProperties = (
17
+ prop: GridResponsiveValue<GridResponsivePropertyValue> | undefined,
18
+ infix: string,
19
+ type: 'spacing' | null = null,
20
+ ): Record<string, GridResponsivePropertyValue> | null => {
21
+ if (typeof prop === 'undefined') {
22
+ return null;
23
+ }
24
+
25
+ if (typeof prop !== 'object') {
26
+ return { [`--rui-local-${infix}-xs`]: prepareValueByType(prop, type) };
27
+ }
28
+
29
+ return Object.keys(prop).reduce<Record<string, GridResponsivePropertyValue>>((acc, breakpoint) => ({
30
+ ...acc,
31
+ [`--rui-local-${infix}-${breakpoint}`]: prepareValueByType(prop[breakpoint as Breakpoint] as GridResponsivePropertyValue, type),
32
+ }), {});
33
+ };
@@ -0,0 +1,9 @@
1
+ export { default as Grid } from './Grid';
2
+ export { default as GridSpan } from './GridSpan';
3
+ export type {
4
+ GridProps,
5
+ GridResponsiveValue,
6
+ GridSpacingValue,
7
+ GridSpanProps,
8
+ GridTag,
9
+ } from './Grid.types';
@@ -50,16 +50,20 @@
50
50
  }
51
51
 
52
52
  // States
53
+ .isRootStateChanged {
54
+ @include variants.state(changed);
55
+ }
56
+
53
57
  .isRootStateInvalid {
54
- @include variants.validation(invalid);
58
+ @include variants.state(invalid);
55
59
  }
56
60
 
57
61
  .isRootStateValid {
58
- @include variants.validation(valid);
62
+ @include variants.state(valid);
59
63
  }
60
64
 
61
65
  .isRootStateWarning {
62
- @include variants.validation(warning);
66
+ @include variants.state(warning);
63
67
  }
64
68
 
65
69
  // Layouts
@@ -1,33 +1,40 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, {
3
2
  useContext,
4
3
  useMemo,
5
4
  } from 'react';
5
+ import type {
6
+ Key,
7
+ ReactElement,
8
+ } from 'react';
6
9
  import { withGlobalProps } from '../../providers/globalProps';
7
10
  import { classNames } from '../../helpers/classNames/classNames';
8
11
  import { transferProps } from '../../helpers/transferProps';
9
12
  import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
10
- import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
13
+ import { getRootStateClassName } from '../_helpers/getRootStateClassName';
11
14
  import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
12
15
  import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
13
- import { FormLayoutContext } from '../FormLayout';
16
+ import { FormLayoutContext } from '../FormLayout/FormLayoutContext';
14
17
  import { Text } from '../Text';
18
+ import type { State } from '../../types';
15
19
  import { InputGroupContext } from './InputGroupContext';
16
20
  import styles from './InputGroup.module.scss';
21
+ import type { InputGroupProps } from './InputGroup.types';
22
+
23
+ const statePriority: State[] = ['invalid', 'warning', 'changed', 'valid'];
17
24
 
18
- export const InputGroup = ({
25
+ export const InputGroup: React.FunctionComponent<InputGroupProps> = ({
19
26
  children,
20
- disabled,
27
+ disabled = false,
21
28
  helpTexts,
22
29
  id,
23
- isLabelVisible,
30
+ isLabelVisible = true,
24
31
  label,
25
- layout,
26
- required,
27
- size,
32
+ layout = 'vertical',
33
+ required = false,
34
+ size = 'medium',
28
35
  validationTexts,
29
36
  ...restProps
30
- }) => {
37
+ }: InputGroupProps) => {
31
38
  const formLayoutContext = useContext(FormLayoutContext);
32
39
  const inputGroupContextValue = useMemo(() => ({
33
40
  disabled,
@@ -39,15 +46,9 @@ export const InputGroup = ({
39
46
  return null;
40
47
  }
41
48
 
42
- const validationState = children.reduce(
43
- (state, child) => {
44
- if (state === 'invalid' || (state === 'warning' && child.props.validationState === 'valid')) {
45
- return state;
46
- }
47
- return child.props.validationState ?? state;
48
- },
49
- null,
50
- );
49
+ const childStates = React.Children.toArray(children)
50
+ .map((child) => (child as ReactElement<{ state?: State }>).props.state);
51
+ const state = statePriority.find((priorityState) => childStates.includes(priorityState));
51
52
 
52
53
  return (
53
54
  <fieldset
@@ -60,8 +61,8 @@ export const InputGroup = ({
60
61
  : styles.isRootLayoutVertical,
61
62
  disabled && styles.isRootDisabled,
62
63
  required && styles.isRootRequired,
63
- getRootSizeClassName(size, styles),
64
- getRootValidationStateClassName(validationState, styles),
64
+ getRootSizeClassName(styles, size),
65
+ getRootStateClassName(styles, state),
65
66
  )}
66
67
  disabled={disabled}
67
68
  id={id}
@@ -96,7 +97,7 @@ export const InputGroup = ({
96
97
  id={id && `${id}__helpTexts`}
97
98
  >
98
99
  {helpTexts.map((helpText) => (
99
- <li key={helpText}>
100
+ <li key={helpText as Key}>
100
101
  <Text blockLevel>
101
102
  {helpText}
102
103
  </Text>
@@ -110,7 +111,7 @@ export const InputGroup = ({
110
111
  id={id && `${id}__validationTexts`}
111
112
  >
112
113
  {validationTexts.map((validationText) => (
113
- <li key={validationText}>
114
+ <li key={validationText as Key}>
114
115
  <Text blockLevel>
115
116
  {validationText}
116
117
  </Text>
@@ -123,77 +124,6 @@ export const InputGroup = ({
123
124
  );
124
125
  };
125
126
 
126
- InputGroup.defaultProps = {
127
- children: undefined,
128
- disabled: false,
129
- helpTexts: undefined,
130
- id: undefined,
131
- isLabelVisible: true,
132
- layout: 'vertical',
133
- required: false,
134
- size: 'medium',
135
- validationTexts: undefined,
136
- };
137
-
138
- InputGroup.propTypes = {
139
- /**
140
- * Supported elements to be grouped:
141
- * * `Button`
142
- * * `SelectField`
143
- * * `TextField`
144
- *
145
- * If none are provided nothing is rendered.
146
- */
147
- children: PropTypes.node,
148
- /**
149
- * If `true`, the whole input group with all nested inputs and buttons will be disabled.
150
- */
151
- disabled: PropTypes.bool,
152
- /**
153
- * An array of help texts to be displayed.
154
- */
155
- helpTexts: PropTypes.arrayOf(PropTypes.node),
156
- /**
157
- * ID of the root HTML element.
158
- *
159
- * Also serves as base for ids of nested elements:
160
- * * `<ID>__label`
161
- * * `<ID>__displayLabel`
162
- * * `<ID>__group`
163
- * * `<ID>__validationTexts`
164
- */
165
- id: PropTypes.string,
166
- /**
167
- * If `false`, the label will be visually hidden (but remains accessible by assistive
168
- * technologies).
169
- */
170
- isLabelVisible: PropTypes.bool,
171
- /**
172
- * Input group label.
173
- */
174
- label: PropTypes.node.isRequired,
175
- /**
176
- * Layout of the group.
177
- *
178
- * Ignored if the component is rendered within `FormLayout` component
179
- * as the value is inherited in such case.
180
- */
181
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
182
- /**
183
- * If `true`, the `InputGroup`'s label appears as required. Underlying `<fieldset>`
184
- * element does not take `required` attribute so there is no functional effect.
185
- */
186
- required: PropTypes.bool,
187
- /**
188
- * Size of the `children` elements.
189
- */
190
- size: PropTypes.oneOf(['small', 'medium', 'large']),
191
- /**
192
- * An array of validation messages to be displayed.
193
- */
194
- validationTexts: PropTypes.arrayOf(PropTypes.node),
195
- };
196
-
197
- export const InputGroupWithGlobalProps = withGlobalProps(InputGroup, 'InputGroup');
127
+ export const InputGroupWithGlobalProps = withGlobalProps<InputGroupProps, never>(InputGroup, 'InputGroup');
198
128
 
199
129
  export default InputGroupWithGlobalProps;
@@ -0,0 +1,80 @@
1
+ import type {
2
+ FieldsetHTMLAttributes,
3
+ ReactNode,
4
+ } from 'react';
5
+ import type {
6
+ Layout,
7
+ Size,
8
+ } from '../../types';
9
+
10
+ /**
11
+ * Props of the `InputGroup` component.
12
+ */
13
+ export type InputGroupProps = Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, 'disabled'> & {
14
+ /**
15
+ * Supported elements to be grouped:
16
+ * * `Button`
17
+ * * `SelectField`
18
+ * * `TextField`
19
+ *
20
+ * If none are provided nothing is rendered.
21
+ */
22
+ children?: ReactNode;
23
+ /**
24
+ * If `true`, the whole input group with all nested inputs and buttons will be disabled.
25
+ */
26
+ disabled?: boolean;
27
+ /**
28
+ * An array of help texts to be displayed.
29
+ */
30
+ helpTexts?: ReactNode[];
31
+ /**
32
+ * ID of the root HTML element.
33
+ *
34
+ * Also serves as base for ids of nested elements:
35
+ * * `<ID>__label`
36
+ * * `<ID>__displayLabel`
37
+ * * `<ID>__group`
38
+ * * `<ID>__validationTexts`
39
+ */
40
+ id?: string;
41
+ /**
42
+ * If `false`, the label will be visually hidden (but remains accessible by assistive
43
+ * technologies).
44
+ */
45
+ isLabelVisible?: boolean;
46
+ /**
47
+ * Input group label.
48
+ */
49
+ label: ReactNode;
50
+ /**
51
+ * Layout of the group.
52
+ *
53
+ * Ignored if the component is rendered within `FormLayout` component
54
+ * as the value is inherited in such case.
55
+ */
56
+ layout?: Layout;
57
+ /**
58
+ * If `true`, the `InputGroup`'s label appears as required. Underlying `<fieldset>`
59
+ * element does not take `required` attribute so there is no functional effect.
60
+ */
61
+ required?: boolean;
62
+ /**
63
+ * Size of the `children` elements.
64
+ */
65
+ size?: Size;
66
+ /**
67
+ * An array of validation messages to be displayed.
68
+ */
69
+ validationTexts?: ReactNode[];
70
+ };
71
+
72
+ /**
73
+ * Values `InputGroup` provides to the fields and buttons rendered inside it.
74
+ */
75
+ export type InputGroupContextValue = {
76
+ disabled: boolean;
77
+ layout: Layout;
78
+ size: Size;
79
+ };
80
+
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { InputGroupContextValue } from './InputGroup.types';
3
+
4
+ export const InputGroupContext = React.createContext<InputGroupContextValue | null>(null);
@@ -73,6 +73,10 @@ See [API](#api) for all available options.
73
73
  [ButtonGroup](/components/ButtonGroup) component which is designed
74
74
  specifically for that purpose.
75
75
 
76
+ - InputGroup can be used inside [FormLayout](/components/FormLayout). In that
77
+ case, its `layout` prop is ignored and the value is inherited from
78
+ FormLayout instead.
79
+
76
80
  ## Sizes
77
81
 
78
82
  All existing field and button sizes are also available on the input group level:
@@ -218,7 +222,7 @@ Disables all fields and buttons inside the group.
218
222
  ### Validation States
219
223
 
220
224
  Validation states visually present the result of validation of the grouped
221
- inputs. Input group's validation state is taken from its child inputs. You
225
+ inputs. Input group's state is taken from its child inputs. You
222
226
  should always **provide validation messages for states other than valid**
223
227
  directly through `validationTexts` prop so users know what happened and what
224
228
  action they should take or what options they have.
@@ -226,7 +230,7 @@ action they should take or what options they have.
226
230
  These messages are not semantically tied to the `children` elements, the
227
231
  connection should be expressed in textual form in the actual message. The
228
232
  individual `children` elements must not show any `validationText`, they only
229
- show their respective `validationState`.
233
+ show their respective `state`.
230
234
 
231
235
  ⚠️ Validation messages passed to input elements' `validationText` prop are
232
236
  ignored within InputGroup.
@@ -248,13 +252,13 @@ for the underlying `<fieldset>` element.
248
252
  label="First name"
249
253
  placeholder="Eg. John"
250
254
  required
251
- validationState="invalid"
255
+ state="invalid"
252
256
  />
253
257
  <TextField
254
258
  label="Last name"
255
259
  placeholder="Eg. Doe"
256
260
  required
257
- validationState="invalid"
261
+ state="invalid"
258
262
  />
259
263
  <Button label="Submit" />
260
264
  </InputGroup>
@@ -275,7 +279,7 @@ for the underlying `<fieldset>` element.
275
279
  label="Last name"
276
280
  placeholder="Eg. Doe"
277
281
  required
278
- validationState="warning"
282
+ state="warning"
279
283
  value="123Doe"
280
284
  />
281
285
  <Button label="Submit" />
@@ -288,14 +292,42 @@ for the underlying `<fieldset>` element.
288
292
  label="First name"
289
293
  placeholder="Eg. John"
290
294
  required
291
- validationState="valid"
295
+ state="valid"
292
296
  value="John"
293
297
  />
294
298
  <TextField
295
299
  label="Last name"
296
300
  placeholder="Eg. Doe"
297
301
  required
298
- validationState="valid"
302
+ state="valid"
303
+ value="Doe"
304
+ />
305
+ <Button label="Submit" />
306
+ </InputGroup>
307
+ ```
308
+
309
+ ### Changed State
310
+
311
+ Changed state highlights inputs whose value differs from the saved one, so users
312
+ can review their edits before saving.
313
+
314
+ Input group shows one state at a time. When its inputs have different states,
315
+ the group takes the one that matters most to the user, in this order:
316
+ `invalid`, `warning`, `changed`, `valid`.
317
+
318
+ ```docoff-react-preview
319
+ <InputGroup label="First and last name">
320
+ <TextField
321
+ label="First name"
322
+ onChange={() => {}}
323
+ placeholder="Eg. John"
324
+ value="John"
325
+ />
326
+ <TextField
327
+ label="Last name"
328
+ onChange={() => {}}
329
+ placeholder="Eg. Doe"
330
+ state="changed"
299
331
  value="Doe"
300
332
  />
301
333
  <Button label="Submit" />
@@ -318,7 +350,7 @@ and helps to improve its accessibility.
318
350
 
319
351
  ## API
320
352
 
321
- <docoff-react-props src="/components/InputGroup/InputGroup.jsx"></docoff-react-props>
353
+ <docoff-react-props src="/components/InputGroup/InputGroup.tsx" name="InputGroup"></docoff-react-props>
322
354
 
323
355
  ## Theming
324
356
 
@@ -1,2 +1,6 @@
1
1
  export { default as InputGroup } from './InputGroup';
2
+ export type {
3
+ InputGroupContextValue,
4
+ InputGroupProps,
5
+ } from './InputGroup.types';
2
6
  export { InputGroupContext } from './InputGroupContext';
@@ -0,0 +1,172 @@
1
+ import React, {
2
+ useCallback,
3
+ useEffect,
4
+ useImperativeHandle,
5
+ useRef,
6
+ } from 'react';
7
+ import type {
8
+ KeyboardEvent,
9
+ MouseEvent,
10
+ ReactNode,
11
+ RefObject,
12
+ SyntheticEvent,
13
+ } from 'react';
14
+ import { createPortal } from 'react-dom';
15
+ import { classNames } from '../../helpers/classNames';
16
+ import { transferProps } from '../../helpers/transferProps';
17
+ import { withGlobalProps } from '../../providers/globalProps';
18
+ import { getRootColorClassName } from '../_helpers/getRootColorClassName';
19
+ import { dialogOnCancelHandler } from './_helpers/dialogOnCancelHandler';
20
+ import { dialogOnClickHandler } from './_helpers/dialogOnClickHandler';
21
+ import { dialogOnCloseHandler } from './_helpers/dialogOnCloseHandler';
22
+ import { dialogOnKeyDownHandler } from './_helpers/dialogOnKeyDownHandler';
23
+ import { getPositionClassName } from './_helpers/getPositionClassName';
24
+ import { getSizeClassName } from './_helpers/getSizeClassName';
25
+ import { useModalFocus } from './_hooks/useModalFocus';
26
+ import { useModalScrollPrevention } from './_hooks/useModalScrollPrevention';
27
+ import styles from './Modal.module.scss';
28
+ import type {
29
+ ModalEvents,
30
+ ModalPosition,
31
+ ModalProps,
32
+ ModalSize,
33
+ } from './Modal.types';
34
+
35
+ const preRender = (
36
+ children: ReactNode,
37
+ color: ModalProps['color'],
38
+ dialogRef: RefObject<HTMLDialogElement | null>,
39
+ position: ModalPosition,
40
+ size: ModalSize,
41
+ events: ModalEvents,
42
+ restProps: Omit<ModalProps, 'children' | 'color' | 'position' | 'size'>,
43
+ ) => (
44
+ <dialog
45
+ {...transferProps(restProps)}
46
+ {...transferProps(events)}
47
+ className={classNames(
48
+ styles.root,
49
+ color && getRootColorClassName(styles, color),
50
+ getSizeClassName(styles, size),
51
+ getPositionClassName(styles, position),
52
+ )}
53
+ ref={dialogRef}
54
+ >
55
+ {children}
56
+ </dialog>
57
+ );
58
+
59
+ export const Modal: React.FunctionComponent<ModalProps> = ({
60
+ allowCloseOnBackdropClick = true,
61
+ allowCloseOnEscapeKey = true,
62
+ allowPrimaryActionOnEnterKey = true,
63
+ autoFocus = true,
64
+ children,
65
+ closeButtonRef,
66
+ color,
67
+ dialogRef,
68
+ portalId,
69
+ position = 'center',
70
+ preventScrollUnderneath = window.document.body,
71
+ primaryButtonRef,
72
+ size = 'medium',
73
+ ...restProps
74
+ }: ModalProps) => {
75
+ const internalDialogRef = useRef<HTMLDialogElement>(null);
76
+ const mouseDownTarget = useRef<EventTarget | null>(null);
77
+
78
+ useEffect(() => {
79
+ internalDialogRef.current?.showModal();
80
+ }, []);
81
+
82
+ // We need to have a reference to the dialog element to be able to call its methods,
83
+ // but at the same time we want to expose this reference to the parent component for
84
+ // case someone wants to call dialog methods from outside the component.
85
+ useImperativeHandle(dialogRef, () => internalDialogRef.current as HTMLDialogElement);
86
+
87
+ useModalFocus(autoFocus, internalDialogRef, primaryButtonRef);
88
+ useModalScrollPrevention(preventScrollUnderneath);
89
+
90
+ const onCancel = useCallback(
91
+ (e: SyntheticEvent<HTMLDialogElement>) => {
92
+ if (e.target !== internalDialogRef.current) {
93
+ return;
94
+ }
95
+ dialogOnCancelHandler(e, closeButtonRef, restProps.onCancel);
96
+ },
97
+ [closeButtonRef, restProps.onCancel],
98
+ );
99
+ const onClick = useCallback(
100
+ (e: MouseEvent<HTMLDialogElement>) => dialogOnClickHandler(
101
+ e,
102
+ closeButtonRef,
103
+ internalDialogRef,
104
+ allowCloseOnBackdropClick,
105
+ mouseDownTarget.current,
106
+ ),
107
+ [allowCloseOnBackdropClick, closeButtonRef, internalDialogRef],
108
+ );
109
+ const onClose = useCallback(
110
+ (e: SyntheticEvent<HTMLDialogElement>) => dialogOnCloseHandler(e, closeButtonRef, restProps.onClose),
111
+ [closeButtonRef, restProps.onClose],
112
+ );
113
+ const onKeyDown = useCallback(
114
+ (e: KeyboardEvent<HTMLDialogElement>) => dialogOnKeyDownHandler(
115
+ e,
116
+ closeButtonRef,
117
+ primaryButtonRef,
118
+ allowCloseOnEscapeKey,
119
+ allowPrimaryActionOnEnterKey,
120
+ ),
121
+ [
122
+ allowCloseOnEscapeKey,
123
+ allowPrimaryActionOnEnterKey,
124
+ closeButtonRef,
125
+ primaryButtonRef,
126
+ ],
127
+ );
128
+
129
+ const onMouseDown = useCallback((e: MouseEvent<HTMLDialogElement>) => {
130
+ mouseDownTarget.current = e.target;
131
+ }, []);
132
+
133
+ const events: ModalEvents = {
134
+ onCancel,
135
+ onClick,
136
+ onClose,
137
+ onKeyDown,
138
+ onMouseDown,
139
+ };
140
+
141
+ // `preRender` only forwards the ref to the `<dialog>` element, it does not read it during render.
142
+ /* eslint-disable react-hooks/refs */
143
+ if (portalId === undefined) {
144
+ return preRender(
145
+ children,
146
+ color,
147
+ internalDialogRef,
148
+ position,
149
+ size,
150
+ events,
151
+ restProps,
152
+ );
153
+ }
154
+
155
+ return createPortal(
156
+ preRender(
157
+ children,
158
+ color,
159
+ internalDialogRef,
160
+ position,
161
+ size,
162
+ events,
163
+ restProps,
164
+ ),
165
+ document.getElementById(portalId) as HTMLElement,
166
+ );
167
+ /* eslint-enable react-hooks/refs */
168
+ };
169
+
170
+ export const ModalWithGlobalProps = withGlobalProps<ModalProps, never>(Modal, 'Modal');
171
+
172
+ export default ModalWithGlobalProps;