@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
@@ -1,21 +1,26 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, { useMemo } from 'react';
2
+ import type { CSSProperties } from 'react';
3
3
  import { withGlobalProps } from '../../providers/globalProps';
4
4
  import { classNames } from '../../helpers/classNames/classNames';
5
5
  import { transferProps } from '../../helpers/transferProps';
6
6
  import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
7
+ import type { Layout } from '../../types';
7
8
  import { FormLayoutContext } from './FormLayoutContext';
8
9
  import styles from './FormLayout.module.scss';
10
+ import type {
11
+ FormLayoutLabelWidth,
12
+ FormLayoutProps,
13
+ } from './FormLayout.types';
9
14
 
10
15
  const PREDEFINED_LABEL_WIDTH_VALUES = ['auto', 'default', 'limited'];
11
16
 
12
- export const FormLayout = ({
13
- autoWidth,
17
+ export const FormLayout: React.FunctionComponent<FormLayoutProps> = ({
18
+ autoWidth = false,
14
19
  children,
15
- fieldLayout,
16
- labelWidth,
20
+ fieldLayout = 'vertical',
21
+ labelWidth = 'default',
17
22
  ...restProps
18
- }) => {
23
+ }: FormLayoutProps) => {
19
24
  const childProps = useMemo(() => ({ layout: fieldLayout }), [fieldLayout]);
20
25
 
21
26
  if (isChildrenEmpty(children)) {
@@ -24,7 +29,7 @@ export const FormLayout = ({
24
29
 
25
30
  const hasCustomLabelWidth = !PREDEFINED_LABEL_WIDTH_VALUES.includes(labelWidth);
26
31
 
27
- const fieldLayoutClass = (layout) => {
32
+ const fieldLayoutClass = (layout: Layout) => {
28
33
  if (layout === 'horizontal') {
29
34
  return styles.isRootFieldLayoutHorizontal;
30
35
  }
@@ -32,7 +37,7 @@ export const FormLayout = ({
32
37
  return styles.isRootFieldLayoutVertical;
33
38
  };
34
39
 
35
- const labelWidthClass = (width) => {
40
+ const labelWidthClass = (width: FormLayoutLabelWidth) => {
36
41
  if (hasCustomLabelWidth) {
37
42
  return styles.hasRootLabelWidthCustom;
38
43
  }
@@ -57,7 +62,7 @@ export const FormLayout = ({
57
62
  autoWidth && styles.isRootAutoWidth,
58
63
  fieldLayout === 'horizontal' && labelWidthClass(labelWidth),
59
64
  )}
60
- {...hasCustomLabelWidth ? { style: { '--rui-custom-label-width': labelWidth } } : {}}
65
+ {...hasCustomLabelWidth ? { style: { '--rui-custom-label-width': labelWidth } as CSSProperties } : {}}
61
66
  >
62
67
  <FormLayoutContext.Provider value={childProps}>
63
68
  {children}
@@ -66,46 +71,6 @@ export const FormLayout = ({
66
71
  );
67
72
  };
68
73
 
69
- FormLayout.defaultProps = {
70
- autoWidth: false,
71
- children: undefined,
72
- fieldLayout: 'vertical',
73
- labelWidth: 'default',
74
- };
75
-
76
- FormLayout.propTypes = {
77
- /**
78
- * If `true`, FormLayout will take up only as much horizontal space as necessary.
79
- */
80
- autoWidth: PropTypes.bool,
81
- /**
82
- * Supported form field components:
83
- * * `CheckboxField`
84
- * * `FileInputField`
85
- * * `FormLayoutCustomField`
86
- * * `Radio`
87
- * * `SelectField`
88
- * * `TextArea`
89
- * * `TextField`
90
- * * `Toggle`
91
- *
92
- * If none are provided nothing is rendered.
93
- */
94
- children: PropTypes.node,
95
- /**
96
- * Layout that is forced on children form fields.
97
- */
98
- fieldLayout: PropTypes.oneOf(['horizontal', 'vertical']),
99
- /**
100
- * Width of the column with form field labels. Only available if the `fieldLayout` is set to
101
- * `horizontal`.
102
- */
103
- labelWidth: PropTypes.oneOfType([
104
- PropTypes.oneOf(PREDEFINED_LABEL_WIDTH_VALUES),
105
- PropTypes.string,
106
- ]),
107
- };
108
-
109
- export const FormLayoutWithGlobalProps = withGlobalProps(FormLayout, 'FormLayout');
74
+ export const FormLayoutWithGlobalProps = withGlobalProps<FormLayoutProps, never>(FormLayout, 'FormLayout');
110
75
 
111
76
  export default FormLayoutWithGlobalProps;
@@ -0,0 +1,55 @@
1
+ import type {
2
+ HTMLAttributes,
3
+ ReactNode,
4
+ } from 'react';
5
+ import type { Layout } from '../../types';
6
+
7
+ export type FormLayoutPredefinedLabelWidth = 'auto' | 'default' | 'limited';
8
+
9
+ /**
10
+ * Either one of the predefined values or any valid CSS width.
11
+ *
12
+ * @docoffOverrideType FormLayoutPredefinedLabelWidth | string
13
+ */
14
+ export type FormLayoutLabelWidth = FormLayoutPredefinedLabelWidth | (string & NonNullable<unknown>);
15
+
16
+ /**
17
+ * Props of the `FormLayout` component.
18
+ */
19
+ export type FormLayoutProps = HTMLAttributes<HTMLDivElement> & {
20
+ /**
21
+ * If `true`, FormLayout will take up only as much horizontal space as necessary.
22
+ */
23
+ autoWidth?: boolean;
24
+ /**
25
+ * Supported form field components:
26
+ * * `CheckboxField`
27
+ * * `FileInputField`
28
+ * * `FormLayoutCustomField`
29
+ * * `Radio`
30
+ * * `SelectField`
31
+ * * `TextArea`
32
+ * * `TextField`
33
+ * * `Toggle`
34
+ *
35
+ * If none are provided nothing is rendered.
36
+ */
37
+ children?: ReactNode;
38
+ /**
39
+ * Layout that is forced on children form fields.
40
+ */
41
+ fieldLayout?: Layout;
42
+ /**
43
+ * Width of the column with form field labels. Only available if the `fieldLayout` is set to
44
+ * `horizontal`.
45
+ */
46
+ labelWidth?: FormLayoutLabelWidth;
47
+ };
48
+
49
+ /**
50
+ * Values `FormLayout` provides to the fields rendered inside it.
51
+ */
52
+ export type FormLayoutContextValue = {
53
+ layout: Layout;
54
+ };
55
+
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { FormLayoutContextValue } from './FormLayout.types';
3
+
4
+ export const FormLayoutContext = React.createContext<FormLayoutContextValue | null>(null);
@@ -19,16 +19,20 @@
19
19
  }
20
20
 
21
21
  // States
22
+ .isRootStateChanged {
23
+ @include variants.state(changed);
24
+ }
25
+
22
26
  .isRootStateInvalid {
23
- @include variants.validation(invalid);
27
+ @include variants.state(invalid);
24
28
  }
25
29
 
26
30
  .isRootStateValid {
27
- @include variants.validation(valid);
31
+ @include variants.state(valid);
28
32
  }
29
33
 
30
34
  .isRootStateWarning {
31
- @include variants.validation(warning);
35
+ @include variants.state(warning);
32
36
  }
33
37
 
34
38
  // Layouts
@@ -1,16 +1,16 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, { useContext } from 'react';
3
2
  import { withGlobalProps } from '../../providers/globalProps';
4
3
  import { classNames } from '../../helpers/classNames/classNames';
5
4
  import { transferProps } from '../../helpers/transferProps';
6
5
  import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
7
- import { getRootValidationStateClassName } from '../_helpers/getRootValidationStateClassName';
6
+ import { getRootStateClassName } from '../_helpers/getRootStateClassName';
8
7
  import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
9
8
  import { FormLayoutContext } from './FormLayoutContext';
10
9
  import { FormLayoutCustomFieldContext } from './FormLayoutCustomFieldContext';
11
10
  import styles from './FormLayoutCustomField.module.scss';
11
+ import type { FormLayoutCustomFieldProps } from './FormLayoutCustomField.types';
12
12
 
13
- const renderLabel = (id, label, labelForId) => {
13
+ const renderLabel = (id: string | undefined, label: string | undefined, labelForId: string | undefined) => {
14
14
  if (labelForId && label) {
15
15
  return (
16
16
  <label
@@ -37,18 +37,18 @@ const renderLabel = (id, label, labelForId) => {
37
37
  return null;
38
38
  };
39
39
 
40
- export const FormLayoutCustomField = ({
40
+ export const FormLayoutCustomField: React.FunctionComponent<FormLayoutCustomFieldProps> = ({
41
41
  children,
42
- fullWidth,
42
+ fullWidth = false,
43
43
  id,
44
- disabled,
44
+ disabled = false,
45
45
  innerFieldSize,
46
46
  label,
47
47
  labelForId,
48
- required,
49
- validationState,
48
+ required = false,
49
+ state,
50
50
  ...restProps
51
- }) => {
51
+ }: FormLayoutCustomFieldProps) => {
52
52
  const context = useContext(FormLayoutContext);
53
53
 
54
54
  if (isChildrenEmpty(children)) {
@@ -64,8 +64,8 @@ export const FormLayoutCustomField = ({
64
64
  context && context.layout === 'horizontal' ? styles.isRootLayoutHorizontal : styles.isRootLayoutVertical,
65
65
  disabled && styles.isRootDisabled,
66
66
  required && styles.isRootRequired,
67
- getRootSizeClassName(innerFieldSize, styles),
68
- getRootValidationStateClassName(validationState, styles),
67
+ getRootSizeClassName(styles, innerFieldSize),
68
+ getRootStateClassName(styles, state),
69
69
  )}
70
70
  id={id}
71
71
  >
@@ -82,61 +82,6 @@ export const FormLayoutCustomField = ({
82
82
  );
83
83
  };
84
84
 
85
- FormLayoutCustomField.defaultProps = {
86
- children: undefined,
87
- disabled: false,
88
- fullWidth: false,
89
- id: undefined,
90
- innerFieldSize: undefined,
91
- label: undefined,
92
- labelForId: undefined,
93
- required: false,
94
- validationState: undefined,
95
- };
96
-
97
- FormLayoutCustomField.propTypes = {
98
- /**
99
- * Custom HTML or React component(s). If none are provided nothing is rendered.
100
- */
101
- children: PropTypes.node,
102
- /**
103
- * If `true`, label will be shown as disabled.
104
- */
105
- disabled: PropTypes.bool,
106
- /**
107
- * If `true`, the field will span the full width of its parent.
108
- */
109
- fullWidth: PropTypes.bool,
110
- /**
111
- * ID of the root HTML element.
112
- *
113
- * Also serves as base for ids of nested elements:
114
- * * `<ID>__field`
115
- * * `<ID>__label`
116
- */
117
- id: PropTypes.string,
118
- /**
119
- * Size of contained form field used to properly align label.
120
- */
121
- innerFieldSize: PropTypes.oneOf(['small', 'medium', 'large']),
122
- /**
123
- * Optional label of the field.
124
- */
125
- label: PropTypes.string,
126
- /**
127
- * Optional ID of labeled field to keep accessibility features. Only available if `label` is set.
128
- */
129
- labelForId: PropTypes.string,
130
- /**
131
- * If `true`, label will be styled as required.
132
- */
133
- required: PropTypes.bool,
134
- /**
135
- * Alter the field to provide feedback based on validation result.
136
- */
137
- validationState: PropTypes.oneOf(['invalid', 'valid', 'warning']),
138
- };
139
-
140
- export const FormLayoutCustomFieldWithGlobalProps = withGlobalProps(FormLayoutCustomField, 'FormLayoutCustomField');
85
+ export const FormLayoutCustomFieldWithGlobalProps = withGlobalProps<FormLayoutCustomFieldProps, never>(FormLayoutCustomField, 'FormLayoutCustomField');
141
86
 
142
87
  export default FormLayoutCustomFieldWithGlobalProps;
@@ -0,0 +1,60 @@
1
+ import type {
2
+ HTMLAttributes,
3
+ ReactNode,
4
+ } from 'react';
5
+ import type {
6
+ Size,
7
+ State,
8
+ } from '../../types';
9
+
10
+ /**
11
+ * Props of the `FormLayoutCustomField` component.
12
+ */
13
+ export type FormLayoutCustomFieldProps = HTMLAttributes<HTMLDivElement> & {
14
+ /**
15
+ * Custom HTML or React component(s). If none are provided nothing is rendered.
16
+ */
17
+ children?: ReactNode;
18
+ /**
19
+ * If `true`, label will be shown as disabled.
20
+ */
21
+ disabled?: boolean;
22
+ /**
23
+ * If `true`, the field will span the full width of its parent.
24
+ */
25
+ fullWidth?: boolean;
26
+ /**
27
+ * ID of the root HTML element.
28
+ *
29
+ * Also serves as base for ids of nested elements:
30
+ * * `<ID>__field`
31
+ * * `<ID>__label`
32
+ */
33
+ id?: string;
34
+ /**
35
+ * Size of contained form field used to properly align label.
36
+ */
37
+ innerFieldSize?: Size;
38
+ /**
39
+ * Optional label of the field.
40
+ */
41
+ label?: string;
42
+ /**
43
+ * Optional ID of labeled field to keep accessibility features. Only available if `label` is set.
44
+ */
45
+ labelForId?: string;
46
+ /**
47
+ * If `true`, label will be styled as required.
48
+ */
49
+ required?: boolean;
50
+ /**
51
+ * Alter the field to reflect the state of its data, e.g. a validation result or a change
52
+ * against the saved value.
53
+ */
54
+ state?: State;
55
+ };
56
+
57
+ /**
58
+ * `true` when rendered inside `FormLayoutCustomField`.
59
+ */
60
+ export type FormLayoutCustomFieldContextValue = boolean;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { FormLayoutCustomFieldContextValue } from './FormLayoutCustomField.types';
3
+
4
+ export const FormLayoutCustomFieldContext = React.createContext<FormLayoutCustomFieldContextValue | null>(null);
@@ -40,16 +40,12 @@ the job: the [CSS grid layout][grid].
40
40
  Do **not** try to put any custom HTML or React components directly into
41
41
  FormLayout without wrapping it with the FormLayoutCustomField first.
42
42
 
43
- 👉 For usage in auto-width Modal, you may need to turn on the `autoWidth` option
44
- for your FormLayout. This prevents FormLayout from unexpectedly growing in
45
- browsers that [don't support][rui-232] [CSS subgrid][subgrid] in cases when
46
- there are longer validation messages or help texts.
47
-
48
43
  ## Supported Form Fields
49
44
 
50
45
  The FormLayout supports buttons and all React UI form fields:
51
46
  [Button](/components/Button), [CheckboxField](/components/CheckboxField),
52
- [FileInputField](/components/FileInputField), [Radio](/components/Radio),
47
+ [FileInputField](/components/FileInputField),
48
+ [InputGroup](/components/InputGroup), [Radio](/components/Radio),
53
49
  [SelectField](/components/SelectField), [TextArea](/components/TextArea),
54
50
  [TextField](/components/TextField), and [Toggle](/components/Toggle).
55
51
 
@@ -118,7 +114,7 @@ React.createElement(() => {
118
114
  <TextField
119
115
  inputSize={6}
120
116
  label="ZIP"
121
- validationState="invalid"
117
+ state="invalid"
122
118
  validationText="ZIP should be 5 to 6 digits long code."
123
119
  />
124
120
  <FormLayoutCustomField label="Country">
@@ -210,9 +206,6 @@ auto width, and limited width. For cases where an individual manual width works
210
206
  better, there is the **local custom width mode** which enables setting a width
211
207
  that is applied just for the current FormLayout.
212
208
 
213
- 👉 All global label width options can be easily [customized](/docs/customize/theming/overview)
214
- with CSS custom properties.
215
-
216
209
  #### Label Width Options
217
210
 
218
211
  - The `default` mode (global) sets the width of all labels to a **global default
@@ -385,7 +378,7 @@ provide labels with optional feedback style.
385
378
  <FormLayout fieldLayout="horizontal" labelWidth="auto">
386
379
  <FormLayoutCustomField
387
380
  label="Custom field label in valid state"
388
- validationState="valid"
381
+ state="valid"
389
382
  >
390
383
  <docoff-placeholder bordered>Custom field content</docoff-placeholder>
391
384
  </FormLayoutCustomField>
@@ -438,13 +431,13 @@ helps to improve its accessibility.
438
431
 
439
432
  ## API
440
433
 
441
- <docoff-react-props src="/components/FormLayout/FormLayout.jsx"></docoff-react-props>
434
+ <docoff-react-props src="/components/FormLayout/FormLayout.tsx" name="FormLayout"></docoff-react-props>
442
435
 
443
436
  ### FormLayoutCustomField API
444
437
 
445
438
  A place for custom content inside FormLayout.
446
439
 
447
- <docoff-react-props src="/components/FormLayout/FormLayoutCustomField.jsx"></docoff-react-props>
440
+ <docoff-react-props src="/components/FormLayout/FormLayoutCustomField.tsx" name="FormLayoutCustomField"></docoff-react-props>
448
441
 
449
442
  ## Theming
450
443
 
@@ -469,6 +462,4 @@ FormLayoutCustomField can be styled using a small subset of
469
462
  [fragments]: https://reactjs.org/docs/fragments.html
470
463
  [grid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
471
464
  [React common props]: https://react.dev/reference/react-dom/components/common#common-props
472
- [rui-232]: https://github.com/react-ui-org/react-ui/issues/232
473
465
  [rui-265]: https://github.com/react-ui-org/react-ui/issues/265
474
- [subgrid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid
@@ -0,0 +1,14 @@
1
+ export { default as FormLayout } from './FormLayout';
2
+ export type {
3
+ FormLayoutContextValue,
4
+ FormLayoutLabelWidth,
5
+ FormLayoutPredefinedLabelWidth,
6
+ FormLayoutProps,
7
+ } from './FormLayout.types';
8
+ export { FormLayoutContext } from './FormLayoutContext';
9
+ export { FormLayoutCustomFieldContext } from './FormLayoutCustomFieldContext';
10
+ export type {
11
+ FormLayoutCustomFieldContextValue,
12
+ FormLayoutCustomFieldProps,
13
+ } from './FormLayoutCustomField.types';
14
+ export { default as FormLayoutCustomField } from './FormLayoutCustomField';
@@ -37,7 +37,7 @@
37
37
  grid-template-columns: var(--rui-local-columns); // 2.
38
38
  grid-template-rows: var(--rui-local-rows); // 2.
39
39
  grid-auto-flow: var(--rui-local-auto-flow); // 2.
40
- grid-gap: var(--rui-local-row-gap) var(--rui-local-column-gap); // 2.
40
+ gap: var(--rui-local-row-gap) var(--rui-local-column-gap); // 2.
41
41
  // stylelint-disable declaration-block-no-redundant-longhand-properties -- 3.
42
42
  align-content: var(--rui-local-align-content); // 2.
43
43
  align-items: var(--rui-local-align-items); // 2.
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { withGlobalProps } from '../../providers/globalProps';
3
+ import { transferProps } from '../../helpers/transferProps';
4
+ import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
5
+ import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
6
+ import styles from './Grid.module.scss';
7
+ import type { GridProps } from './Grid.types';
8
+
9
+ export const Grid: React.FunctionComponent<GridProps> = ({
10
+ alignContent,
11
+ alignItems,
12
+ autoFlow,
13
+ children,
14
+ columnGap = 4,
15
+ columns = '1fr',
16
+ justifyContent,
17
+ justifyItems,
18
+ rowGap = 4,
19
+ rows = 'auto',
20
+ tag: Tag = 'div',
21
+ ...restProps
22
+ }: GridProps) => {
23
+ if (isChildrenEmpty(children)) {
24
+ return null;
25
+ }
26
+
27
+ return (
28
+ <Tag
29
+ {...transferProps(restProps)}
30
+ className={styles.root}
31
+ style={{
32
+ ...generateResponsiveCustomProperties(columns, 'columns'),
33
+ ...generateResponsiveCustomProperties(columnGap, 'column-gap', 'spacing'),
34
+ ...generateResponsiveCustomProperties(rows, 'rows'),
35
+ ...generateResponsiveCustomProperties(rowGap, 'row-gap', 'spacing'),
36
+ ...generateResponsiveCustomProperties(autoFlow, 'auto-flow'),
37
+ ...generateResponsiveCustomProperties(alignContent, 'align-content'),
38
+ ...generateResponsiveCustomProperties(alignItems, 'align-items'),
39
+ ...generateResponsiveCustomProperties(justifyContent, 'justify-content'),
40
+ ...generateResponsiveCustomProperties(justifyItems, 'justify-items'),
41
+ }}
42
+ >
43
+ {children}
44
+ </Tag>
45
+ );
46
+ };
47
+
48
+ export const GridWithGlobalProps = withGlobalProps<GridProps, HTMLElement>(Grid, 'Grid');
49
+
50
+ export default GridWithGlobalProps;
@@ -0,0 +1,108 @@
1
+ import type {
2
+ HTMLAttributes,
3
+ JSX,
4
+ ReactNode,
5
+ } from 'react';
6
+ import type { Breakpoint } from '../../types';
7
+
8
+ /**
9
+ * A value that is either the same for all breakpoints or defined per breakpoint.
10
+ */
11
+ export type GridResponsiveValue<Value> = Value | Partial<Record<Breakpoint, Value>>;
12
+
13
+ export type GridSpacingValue = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
14
+
15
+ /**
16
+ * Any valid HTML tag.
17
+ *
18
+ * @docoffOverrideType string
19
+ */
20
+ export type GridTag = keyof JSX.IntrinsicElements & keyof HTMLElementTagNameMap;
21
+
22
+ /**
23
+ * Props of the `Grid` component.
24
+ */
25
+ export type GridProps = HTMLAttributes<HTMLElement> & {
26
+ /**
27
+ * Content alignment. Accepts any valid value of `align-content` CSS property.
28
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) for more.
29
+ */
30
+ alignContent?: GridResponsiveValue<string>;
31
+ /**
32
+ * Items alignment. Accepts any valid value of `align-items` CSS property.
33
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) for more.
34
+ */
35
+ alignItems?: GridResponsiveValue<string>;
36
+ /**
37
+ * Grid auto-flow algorithm to be used. Accepts any valid value of `grid-auto-flow` CSS property.
38
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) for more.
39
+ */
40
+ autoFlow?: GridResponsiveValue<string>;
41
+ /**
42
+ * Items to be aligned in the grid. If none are provided nothing is rendered.
43
+ */
44
+ children?: ReactNode;
45
+ /**
46
+ * Gap between columns. Accepts any of [spacing values](/docs/foundation/spacing-values) as number.
47
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more about `column-gap`.
48
+ */
49
+ columnGap?: GridResponsiveValue<GridSpacingValue>;
50
+ /**
51
+ * Grid columns. Accepts any valid value of `grid-template-columns` CSS property.
52
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) for more.
53
+ */
54
+ columns?: GridResponsiveValue<string>;
55
+ /**
56
+ * Content justification. Accepts any valid value of `justify-content` CSS property.
57
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) for more.
58
+ */
59
+ justifyContent?: GridResponsiveValue<string>;
60
+ /**
61
+ * Items justification. Accepts any valid value of `justify-items` CSS property.
62
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) for more.
63
+ */
64
+ justifyItems?: GridResponsiveValue<string>;
65
+ /**
66
+ * Gap between rows. Accepts any of [spacing values](/docs/foundation/spacing-values) as number.
67
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more about `row-gap`.
68
+ */
69
+ rowGap?: GridResponsiveValue<GridSpacingValue>;
70
+ /**
71
+ * Grid rows. Accepts any valid value of `grid-template-rows` CSS property.
72
+ * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows) for more.
73
+ */
74
+ rows?: GridResponsiveValue<string>;
75
+ /**
76
+ * HTML tag to render. Can be any valid HTML tag of your choice, usually a
77
+ * [block-level element](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
78
+ */
79
+ tag?: GridTag;
80
+ };
81
+
82
+ /**
83
+ * Props of the `GridSpan` component.
84
+ */
85
+ export type GridSpanProps = HTMLAttributes<HTMLElement> & {
86
+ /**
87
+ * Items to be aligned in the grid. If none are provided nothing is rendered.
88
+ */
89
+ children?: ReactNode;
90
+ /**
91
+ * Number of columns to span.
92
+ */
93
+ columns?: GridResponsiveValue<number>;
94
+ /**
95
+ * Number of rows to span.
96
+ */
97
+ rows?: GridResponsiveValue<number>;
98
+ /**
99
+ * HTML tag to render. Can be any valid HTML tag of your choice, usually a
100
+ * [block-level element](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements).
101
+ */
102
+ tag?: GridTag;
103
+ };
104
+
105
+ /**
106
+ * Value of a single breakpoint of a responsive Grid prop.
107
+ */
108
+ export type GridResponsivePropertyValue = string | number;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { withGlobalProps } from '../../providers/globalProps';
3
+ import { transferProps } from '../../helpers/transferProps';
4
+ import { isChildrenEmpty } from '../../helpers/isChildrenEmpty/isChildrenEmpty';
5
+ import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
6
+ import styles from './Grid.module.scss';
7
+ import type { GridSpanProps } from './Grid.types';
8
+
9
+ export const GridSpan: React.FunctionComponent<GridSpanProps> = ({
10
+ children,
11
+ columns = 1,
12
+ rows = 1,
13
+ tag: Tag = 'div',
14
+ ...restProps
15
+ }: GridSpanProps) => {
16
+ if (isChildrenEmpty(children)) {
17
+ return null;
18
+ }
19
+
20
+ return (
21
+ <Tag
22
+ {...transferProps(restProps)}
23
+ className={styles.span}
24
+ style={{
25
+ ...generateResponsiveCustomProperties(columns, 'column-span'),
26
+ ...generateResponsiveCustomProperties(rows, 'row-span'),
27
+ }}
28
+ >
29
+ {children}
30
+ </Tag>
31
+ );
32
+ };
33
+
34
+ export const GridSpanWithGlobalProps = withGlobalProps<GridSpanProps, HTMLElement>(GridSpan, 'GridSpan');
35
+
36
+ export default GridSpanWithGlobalProps;