@react-ui-org/react-ui 0.52.0 → 0.53.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. package/CODEOWNERS +23 -0
  2. package/README.md +10 -7
  3. package/dist/react-ui.css +42 -0
  4. package/dist/react-ui.js +1 -0
  5. package/package.json +64 -77
  6. package/src/{lib/components → components}/Alert/Alert.jsx +1 -1
  7. package/src/{lib/components/Alert/README.mdx → components/Alert/README.md} +84 -100
  8. package/src/{lib/components → components}/Badge/Badge.jsx +1 -1
  9. package/src/{lib/components → components}/Badge/Badge.scss +1 -1
  10. package/src/components/Badge/README.md +103 -0
  11. package/src/{lib/components → components}/Button/Button.jsx +1 -1
  12. package/src/components/Button/README.md +580 -0
  13. package/src/{lib/components → components}/ButtonGroup/ButtonGroup.jsx +11 -9
  14. package/src/{lib/components/ButtonGroup/README.mdx → components/ButtonGroup/README.md} +128 -134
  15. package/src/{lib/components → components}/Card/Card.jsx +1 -1
  16. package/src/components/Card/README.md +314 -0
  17. package/src/{lib/components/CheckboxField/README.mdx → components/CheckboxField/README.md} +96 -108
  18. package/src/{lib/components/FileInputField/README.mdx → components/FileInputField/README.md} +83 -95
  19. package/src/{lib/components → components}/FormLayout/FormLayout.jsx +4 -4
  20. package/src/components/FormLayout/README.md +462 -0
  21. package/src/{lib/components → components}/Grid/Grid.jsx +2 -2
  22. package/src/components/Grid/README.md +281 -0
  23. package/src/{lib/components → components}/InputGroup/InputGroup.jsx +20 -19
  24. package/src/{lib/components → components}/InputGroup/InputGroup.scss +1 -6
  25. package/src/{lib/components/InputGroup/README.mdx → components/InputGroup/README.md} +145 -163
  26. package/src/{lib/components → components}/Modal/Modal.jsx +6 -6
  27. package/src/components/Modal/README.md +1090 -0
  28. package/src/components/Modal/_hooks/useModalScrollPrevention.js +37 -0
  29. package/src/{lib/components/Paper/README.mdx → components/Paper/README.md} +18 -30
  30. package/src/{lib/components/Popover/README.mdx → components/Popover/README.md} +102 -132
  31. package/src/{lib/components/Radio/README.mdx → components/Radio/README.md} +122 -134
  32. package/src/{lib/components → components}/Radio/Radio.jsx +11 -12
  33. package/src/{lib/components → components}/Radio/Radio.scss +1 -6
  34. package/src/components/ScrollView/README.md +503 -0
  35. package/src/{lib/components → components}/ScrollView/ScrollView.jsx +12 -3
  36. package/src/components/SelectField/README.md +681 -0
  37. package/src/components/Table/README.md +259 -0
  38. package/src/{lib/components → components}/Table/Table.jsx +4 -1
  39. package/src/{lib/components → components}/Table/_components/TableHeaderCell/TableHeaderCell.jsx +1 -1
  40. package/src/{lib/components/Tabs/README.mdx → components/Tabs/README.md} +117 -134
  41. package/src/{lib/components → components}/Tabs/TabsItem.jsx +3 -3
  42. package/src/components/Text/README.md +220 -0
  43. package/src/components/TextArea/README.md +359 -0
  44. package/src/{lib/components/TextField/README.mdx → components/TextField/README.md} +336 -342
  45. package/src/{lib/components/TextLink/README.mdx → components/TextLink/README.md} +19 -31
  46. package/src/{lib/components/Toggle/README.mdx → components/Toggle/README.md} +98 -110
  47. package/src/components/Toolbar/README.md +359 -0
  48. package/src/{lib/components → components}/Toolbar/_helpers/getAlignClassName.js +12 -4
  49. package/src/components/_helpers/getRootPriorityClassName.js +15 -0
  50. package/src/{lib/index.js → index.js} +6 -0
  51. package/src/{lib/provider → provider}/RUIProvider.jsx +17 -11
  52. package/src/{lib/styles → styles}/tools/_caret.scss +1 -1
  53. package/src/{lib/styles → styles}/tools/form-fields/_box-field-elements.scss +1 -1
  54. package/src/{lib/styles → styles}/tools/form-fields/_box-field-layout.scss +26 -14
  55. package/src/{lib/styles → styles}/tools/form-fields/_inline-field-elements.scss +2 -2
  56. package/src/{lib/theme.scss → theme.scss} +4 -3
  57. package/CONTRIBUTING.md +0 -137
  58. package/dist/lib.development.js +0 -3179
  59. package/dist/lib.js +0 -1
  60. package/public/racom.svg +0 -11
  61. package/src/lib/components/Badge/README.mdx +0 -126
  62. package/src/lib/components/Button/README.mdx +0 -581
  63. package/src/lib/components/Card/README.mdx +0 -326
  64. package/src/lib/components/FormLayout/README.mdx +0 -501
  65. package/src/lib/components/Grid/README.mdx +0 -299
  66. package/src/lib/components/Modal/README.mdx +0 -1360
  67. package/src/lib/components/Modal/_hooks/useModalScrollPrevention.js +0 -35
  68. package/src/lib/components/ScrollView/README.mdx +0 -521
  69. package/src/lib/components/SelectField/README.mdx +0 -693
  70. package/src/lib/components/Table/README.mdx +0 -275
  71. package/src/lib/components/Text/README.mdx +0 -241
  72. package/src/lib/components/TextArea/README.mdx +0 -366
  73. package/src/lib/components/Toolbar/README.mdx +0 -386
  74. package/src/{lib/components → components}/Alert/Alert.scss +0 -0
  75. package/src/{lib/components → components}/Alert/_settings.scss +0 -0
  76. package/src/{lib/components → components}/Alert/_theme.scss +0 -0
  77. package/src/{lib/components → components}/Alert/_tools.scss +0 -0
  78. package/src/{lib/components → components}/Alert/index.js +0 -0
  79. package/src/{lib/components → components}/Badge/index.js +0 -0
  80. package/src/{lib/components → components}/Button/Button.scss +0 -0
  81. package/src/{lib/components → components}/Button/_base.scss +0 -0
  82. package/src/{lib/components → components}/Button/_priorities.scss +0 -0
  83. package/src/{lib/components → components}/Button/_settings.scss +0 -0
  84. package/src/{lib/components → components}/Button/_theme.scss +0 -0
  85. package/src/{lib/components → components}/Button/_tools.scss +0 -0
  86. package/src/{lib/components → components}/Button/helpers/getRootLabelVisibilityClassName.js +0 -0
  87. package/src/{lib/components/_helpers → components/Button/helpers}/getRootPriorityClassName.js +0 -0
  88. package/src/{lib/components → components}/Button/index.js +0 -0
  89. package/src/{lib/components → components}/ButtonGroup/ButtonGroup.scss +0 -0
  90. package/src/{lib/components → components}/ButtonGroup/ButtonGroupContext.js +0 -0
  91. package/src/{lib/components → components}/ButtonGroup/_theme.scss +0 -0
  92. package/src/{lib/components → components}/ButtonGroup/index.js +0 -0
  93. package/src/{lib/components → components}/Card/Card.scss +0 -0
  94. package/src/{lib/components → components}/Card/CardBody.jsx +0 -0
  95. package/src/{lib/components → components}/Card/CardFooter.jsx +0 -0
  96. package/src/{lib/components → components}/Card/_theme.scss +0 -0
  97. package/src/{lib/components → components}/Card/_tools.scss +0 -0
  98. package/src/{lib/components → components}/Card/index.js +0 -0
  99. package/src/{lib/components → components}/CheckboxField/CheckboxField.jsx +0 -0
  100. package/src/{lib/components → components}/CheckboxField/CheckboxField.scss +0 -0
  101. package/src/{lib/components → components}/CheckboxField/index.js +0 -0
  102. package/src/{lib/components → components}/FileInputField/FileInputField.jsx +0 -0
  103. package/src/{lib/components → components}/FileInputField/FileInputField.scss +0 -0
  104. package/src/{lib/components → components}/FileInputField/index.js +0 -0
  105. package/src/{lib/components → components}/FormLayout/FormLayout.scss +0 -0
  106. package/src/{lib/components → components}/FormLayout/FormLayoutContext.js +0 -0
  107. package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.jsx +4 -4
  108. package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.scss +0 -0
  109. package/src/{lib/components → components}/FormLayout/_theme.scss +0 -0
  110. package/src/{lib/components → components}/FormLayout/index.js +0 -0
  111. package/src/{lib/components → components}/Grid/Grid.scss +0 -0
  112. package/src/{lib/components → components}/Grid/GridSpan.jsx +0 -0
  113. package/src/{lib/components → components}/Grid/_helpers/generateResponsiveCustomProperties.js +0 -0
  114. package/src/{lib/components → components}/Grid/_settings.scss +0 -0
  115. package/src/{lib/components → components}/Grid/_tools.scss +0 -0
  116. package/src/{lib/components → components}/Grid/index.js +0 -0
  117. package/src/{lib/components → components}/InputGroup/InputGroupContext.js +0 -0
  118. package/src/{lib/components → components}/InputGroup/_theme.scss +0 -0
  119. package/src/{lib/components → components}/InputGroup/index.js +0 -0
  120. package/src/{lib/components → components}/Modal/Modal.scss +0 -0
  121. package/src/{lib/components → components}/Modal/ModalBody.jsx +0 -0
  122. package/src/{lib/components → components}/Modal/ModalBody.scss +0 -0
  123. package/src/{lib/components → components}/Modal/ModalCloseButton.jsx +1 -1
  124. package/src/{lib/components → components}/Modal/ModalCloseButton.scss +0 -0
  125. package/src/{lib/components → components}/Modal/ModalContent.jsx +0 -0
  126. package/src/{lib/components → components}/Modal/ModalContent.scss +0 -0
  127. package/src/{lib/components → components}/Modal/ModalFooter.jsx +0 -0
  128. package/src/{lib/components → components}/Modal/ModalFooter.scss +0 -0
  129. package/src/{lib/components → components}/Modal/ModalHeader.jsx +0 -0
  130. package/src/{lib/components → components}/Modal/ModalHeader.scss +0 -0
  131. package/src/{lib/components → components}/Modal/ModalTitle.jsx +0 -0
  132. package/src/{lib/components → components}/Modal/ModalTitle.scss +0 -0
  133. package/src/{lib/components → components}/Modal/_helpers/getJustifyClassName.js +0 -0
  134. package/src/{lib/components → components}/Modal/_helpers/getPositionClassName.js +0 -0
  135. package/src/{lib/components → components}/Modal/_helpers/getScrollingClassName.js +0 -0
  136. package/src/{lib/components → components}/Modal/_helpers/getSizeClassName.js +0 -0
  137. package/src/{lib/components → components}/Modal/_hooks/useModalFocus.js +0 -0
  138. package/src/{lib/components → components}/Modal/_settings.scss +0 -0
  139. package/src/{lib/components → components}/Modal/_theme.scss +0 -0
  140. package/src/{lib/components → components}/Modal/index.js +0 -0
  141. package/src/{lib/components → components}/Paper/Paper.jsx +0 -0
  142. package/src/{lib/components → components}/Paper/Paper.scss +0 -0
  143. package/src/{lib/components → components}/Paper/_theme.scss +0 -0
  144. package/src/{lib/components → components}/Paper/index.js +0 -0
  145. package/src/{lib/components → components}/Popover/Popover.jsx +0 -0
  146. package/src/{lib/components → components}/Popover/Popover.scss +0 -0
  147. package/src/{lib/components → components}/Popover/PopoverWrapper.jsx +0 -0
  148. package/src/{lib/components → components}/Popover/PopoverWrapper.scss +0 -0
  149. package/src/{lib/components → components}/Popover/_helpers/getRootAlignmentClassName.js +0 -0
  150. package/src/{lib/components → components}/Popover/_helpers/getRootSideClassName.js +0 -0
  151. package/src/{lib/components → components}/Popover/_theme.scss +0 -0
  152. package/src/{lib/components → components}/Popover/index.js +0 -0
  153. package/src/{lib/components → components}/Radio/index.js +0 -0
  154. package/src/{lib/components → components}/ScrollView/ScrollView.scss +0 -0
  155. package/src/{lib/components → components}/ScrollView/_helpers/getElementsPositionDifference.js +0 -0
  156. package/src/{lib/components → components}/ScrollView/_hooks/useLoadResizeHook.js +0 -0
  157. package/src/{lib/components → components}/ScrollView/_hooks/useScrollPositionHook.js +0 -0
  158. package/src/{lib/components → components}/ScrollView/index.js +0 -0
  159. package/src/{lib/components → components}/SelectField/SelectField.jsx +0 -0
  160. package/src/{lib/components → components}/SelectField/SelectField.scss +0 -0
  161. package/src/{lib/components → components}/SelectField/_components/Option/Option.jsx +0 -0
  162. package/src/{lib/components → components}/SelectField/_components/Option/index.js +0 -0
  163. package/src/{lib/components → components}/SelectField/index.js +0 -0
  164. package/src/{lib/components → components}/Table/Table.scss +0 -0
  165. package/src/{lib/components → components}/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -0
  166. package/src/{lib/components → components}/Table/_components/TableBodyCell/index.js +0 -0
  167. package/src/{lib/components → components}/Table/_components/TableCell.scss +0 -0
  168. package/src/{lib/components → components}/Table/_components/TableHeaderCell/index.js +0 -0
  169. package/src/{lib/components → components}/Table/_settings.scss +0 -0
  170. package/src/{lib/components → components}/Table/index.js +0 -0
  171. package/src/{lib/components → components}/Tabs/Tabs.jsx +0 -0
  172. package/src/{lib/components → components}/Tabs/Tabs.scss +0 -0
  173. package/src/{lib/components → components}/Tabs/TabsItem.scss +0 -0
  174. package/src/{lib/components → components}/Tabs/_theme.scss +0 -0
  175. package/src/{lib/components → components}/Tabs/index.js +0 -0
  176. package/src/{lib/components → components}/Text/Text.jsx +0 -0
  177. package/src/{lib/components → components}/Text/Text.scss +0 -0
  178. package/src/{lib/components → components}/Text/_helpers/getRootClampClassName.js +0 -0
  179. package/src/{lib/components → components}/Text/_helpers/getRootHyphensClassName.js +0 -0
  180. package/src/{lib/components → components}/Text/_helpers/getRootWordWrappingClassName.js +0 -0
  181. package/src/{lib/components → components}/Text/index.js +0 -0
  182. package/src/{lib/components → components}/TextArea/TextArea.jsx +0 -0
  183. package/src/{lib/components → components}/TextArea/TextArea.scss +0 -0
  184. package/src/{lib/components → components}/TextArea/index.js +0 -0
  185. package/src/{lib/components → components}/TextField/TextField.jsx +0 -0
  186. package/src/{lib/components → components}/TextField/TextField.scss +0 -0
  187. package/src/{lib/components → components}/TextField/index.js +0 -0
  188. package/src/{lib/components → components}/TextLink/TextLink.jsx +1 -1
  189. /package/src/{lib/components → components}/TextLink/TextLink.scss +0 -0
  190. /package/src/{lib/components → components}/TextLink/_theme.scss +0 -0
  191. /package/src/{lib/components → components}/TextLink/index.js +0 -0
  192. /package/src/{lib/components → components}/Toggle/Toggle.jsx +0 -0
  193. /package/src/{lib/components → components}/Toggle/Toggle.scss +0 -0
  194. /package/src/{lib/components → components}/Toggle/index.js +0 -0
  195. /package/src/{lib/components → components}/Toolbar/Toolbar.jsx +0 -0
  196. /package/src/{lib/components → components}/Toolbar/Toolbar.scss +0 -0
  197. /package/src/{lib/components → components}/Toolbar/ToolbarGroup.jsx +0 -0
  198. /package/src/{lib/components → components}/Toolbar/ToolbarItem.jsx +0 -0
  199. /package/src/{lib/components → components}/Toolbar/_helpers/getJustifyClassName.js +0 -0
  200. /package/src/{lib/components → components}/Toolbar/_theme.scss +0 -0
  201. /package/src/{lib/components → components}/Toolbar/index.js +0 -0
  202. /package/src/{lib/components → components}/_helpers/getRootColorClassName.js +0 -0
  203. /package/src/{lib/components → components}/_helpers/getRootSizeClassName.js +0 -0
  204. /package/src/{lib/components → components}/_helpers/getRootValidationStateClassName.js +0 -0
  205. /package/src/{lib/components → components}/_helpers/isChildrenEmpty.js +0 -0
  206. /package/src/{lib/components → components}/_helpers/resolveContextOrProp.js +0 -0
  207. /package/src/{lib/components → components}/_helpers/transferProps.js +0 -0
  208. /package/src/{lib/foundation.scss → foundation.scss} +0 -0
  209. /package/src/{lib/helpers.scss → helpers.scss} +0 -0
  210. /package/src/{lib/provider → provider}/RUIContext.jsx +0 -0
  211. /package/src/{lib/provider → provider}/index.js +0 -0
  212. /package/src/{lib/provider → provider}/withGlobalProps.jsx +0 -0
  213. /package/src/{lib/styles → styles}/_utilities.scss +0 -0
  214. /package/src/{lib/styles → styles}/elements/_code.scss +0 -0
  215. /package/src/{lib/styles → styles}/elements/_links.scss +0 -0
  216. /package/src/{lib/styles → styles}/elements/_lists.scss +0 -0
  217. /package/src/{lib/styles → styles}/elements/_page.scss +0 -0
  218. /package/src/{lib/styles → styles}/elements/_rulers.scss +0 -0
  219. /package/src/{lib/styles → styles}/elements/_small.scss +0 -0
  220. /package/src/{lib/styles → styles}/generic/_box-sizing.scss +0 -0
  221. /package/src/{lib/styles → styles}/generic/_focus.scss +0 -0
  222. /package/src/{lib/styles → styles}/generic/_forms.scss +0 -0
  223. /package/src/{lib/styles → styles}/generic/_reset.scss +0 -0
  224. /package/src/{lib/styles → styles}/generic/_shared.scss +0 -0
  225. /package/src/{lib/styles → styles}/helpers/_animation.scss +0 -0
  226. /package/src/{lib/styles → styles}/settings/_animations.scss +0 -0
  227. /package/src/{lib/styles → styles}/settings/_breakpoints.scss +0 -0
  228. /package/src/{lib/styles → styles}/settings/_escaped-characters.scss +0 -0
  229. /package/src/{lib/styles → styles}/settings/_form-fields.scss +0 -0
  230. /package/src/{lib/styles → styles}/settings/_forms.scss +0 -0
  231. /package/src/{lib/styles → styles}/settings/_utilities.scss +0 -0
  232. /package/src/{lib/styles → styles}/settings/_z-indexes.scss +0 -0
  233. /package/src/{lib/styles → styles}/theme/_accessibility.scss +0 -0
  234. /package/src/{lib/styles → styles}/theme/_borders.scss +0 -0
  235. /package/src/{lib/styles → styles}/theme/_code.scss +0 -0
  236. /package/src/{lib/styles → styles}/theme/_form-fields.scss +0 -0
  237. /package/src/{lib/styles → styles}/theme/_links.scss +0 -0
  238. /package/src/{lib/styles → styles}/theme/_lists.scss +0 -0
  239. /package/src/{lib/styles → styles}/theme/_page.scss +0 -0
  240. /package/src/{lib/styles → styles}/theme/_spacing.scss +0 -0
  241. /package/src/{lib/styles → styles}/theme/_typography.scss +0 -0
  242. /package/src/{lib/styles → styles}/theme-constants/_breakpoints.scss +0 -0
  243. /package/src/{lib/styles → styles}/theme-constants/_colors.scss +0 -0
  244. /package/src/{lib/styles → styles}/theme-constants/_svg.scss +0 -0
  245. /package/src/{lib/styles → styles}/tools/_accessibility.scss +0 -0
  246. /package/src/{lib/styles → styles}/tools/_breakpoint.scss +0 -0
  247. /package/src/{lib/styles → styles}/tools/_colors.scss +0 -0
  248. /package/src/{lib/styles → styles}/tools/_reset.scss +0 -0
  249. /package/src/{lib/styles → styles}/tools/_scrollbar.scss +0 -0
  250. /package/src/{lib/styles → styles}/tools/_spacing.scss +0 -0
  251. /package/src/{lib/styles → styles}/tools/_string.scss +0 -0
  252. /package/src/{lib/styles → styles}/tools/_svg.scss +0 -0
  253. /package/src/{lib/styles → styles}/tools/_transition.scss +0 -0
  254. /package/src/{lib/styles → styles}/tools/_utilities.scss +0 -0
  255. /package/src/{lib/styles → styles}/tools/form-fields/_box-field-sizes.scss +0 -0
  256. /package/src/{lib/styles → styles}/tools/form-fields/_foundation.scss +0 -0
  257. /package/src/{lib/styles → styles}/tools/form-fields/_inline-field-layout.scss +0 -0
  258. /package/src/{lib/styles → styles}/tools/form-fields/_variants.scss +0 -0
  259. /package/src/{lib/translations → translations}/en.js +0 -0
  260. /package/src/{lib/utils → utils}/classNames.js +0 -0
@@ -0,0 +1,462 @@
1
+ # FormLayout
2
+
3
+ The FormLayout aligns form fields into an organized grid.
4
+
5
+ ## Basic Usage
6
+
7
+ To implement the FormLayout component, you need to import it first:
8
+
9
+ ```js
10
+ import { FormLayout } from '@react-ui-org/react-ui';
11
+ ```
12
+
13
+ And use it:
14
+
15
+ ```docoff-react-preview
16
+ <FormLayout>
17
+ <TextField label="A form element" />
18
+ </FormLayout>
19
+ ```
20
+
21
+ See [API](#api) for all available options.
22
+
23
+ ## General Guidelines
24
+
25
+ Since all form fields in React UI are styled as inline blocks, they **queue up
26
+ one after another in a row by default.** The FormLayout component is there to
27
+ make building **vertical and horizontal forms** easy. It uses the right tool for
28
+ the job: the [CSS grid layout][grid].
29
+
30
+ - Put **only form field components** from React UI inside the FormLayout and
31
+ make sure they are **direct descendants** of it (React [fragments] are
32
+ supported!). All React UI form components are ready for this use case and
33
+ don't need to be wrapped in any `div`s. Namely, the FormLayout supports the
34
+ following React UI components:
35
+ [CheckboxField](/components/CheckboxField),
36
+ [Radio](/components/Radio), [SelectField](/components/SelectField),
37
+ [TextArea](/components/TextArea), [TextField](/components/TextField),
38
+ and [Toggle](/components/Toggle).
39
+
40
+ - Use the [FormLayoutCustomField](#custom-fields) component when you need to
41
+ place any **custom content** inside the FormLayout. This layout helper ensures
42
+ your content is properly spaced and aligned with other FormLayout elements.
43
+ Do **not** try to put any custom HTML or React components directly into
44
+ FormLayout without wrapping it with the FormLayoutCustomField first.
45
+
46
+ 👉 For usage in auto-width Modal, you may need to turn on the `autoWidth` option
47
+ for your FormLayout. This prevents FormLayout from unexpectedly growing in
48
+ browsers that [don't support][rui-232] [CSS subgrid][subgrid] in cases when
49
+ there are longer validation messages or help texts.
50
+
51
+ ## Vertical Layout
52
+
53
+ Vertical FormLayout works similar to single-column [Grid](/components/Grid)
54
+ layout while it also forces vertical layout mode on form fields. To use this
55
+ layout, simply wrap your form fields with the FormLayout component:
56
+
57
+ ```docoff-react-preview
58
+ <FormLayout>
59
+ <TextField label="A form element" />
60
+ <TextField label="Another form element" />
61
+ <TextField label="Yet another one" />
62
+ </FormLayout>
63
+ ```
64
+
65
+ ## Horizontal Layout
66
+
67
+ Horizontal FormLayout is designed for horizontal form fields: it nicely **aligns
68
+ labels and inputs in an organized grid.** It is applied starting from the `md`
69
+ viewport size onward and it forces the horizontal layout on the fields.
70
+
71
+ ```docoff-react-preview
72
+ <FormLayout fieldLayout="horizontal">
73
+ <TextField label="A form element" />
74
+ <TextField label="Another form element" />
75
+ <TextField label="Yet another one" />
76
+ </FormLayout>
77
+ ```
78
+
79
+ ### Label Width
80
+
81
+ In the horizontal layout mode, it's possible to fine-tune the way how the form
82
+ will be aligned through the `labelWidth` option to cover various design
83
+ requirements. It comes with **three globally shared options:** default width,
84
+ auto width, and limited width. For cases where an individual manual width works
85
+ better, there is the **local custom width mode** which enables setting a width
86
+ that is applied just for the current FormLayout.
87
+
88
+ 👉 All global label width options can be easily [customized](/docs/customize/theming/overview)
89
+ with CSS custom properties.
90
+
91
+ #### Label Width Options
92
+
93
+ - The `default` mode (global) sets the width of all labels to a **global default
94
+ value** which is 10 em.
95
+
96
+ - The `auto` mode (global) aligns the form **according to the longest label.**
97
+
98
+ - The `limited` mode (global) works as `auto` except it's intended for values
99
+ that **set a limit for the label width.** Its default value is
100
+ `fitcontent(50%)` which also aligns the form according to the longest label
101
+ like `auto`, but with the difference that the labels cannot be wider than
102
+ 50 % of the FormLayout.
103
+
104
+ - The `custom` mode (local) allows you to enter any **custom label width for
105
+ individual FormLayouts.**
106
+
107
+ ```docoff-react-preview
108
+ React.createElement(() => {
109
+ const [labelWidth, setLabelWidth] = React.useState('default');
110
+ const [customLabelWidth, setCustomLabelWidth] = React.useState('20em');
111
+ return (
112
+ <div>
113
+ <Toolbar align="baseline">
114
+ <ToolbarItem>
115
+ <span id="label-width-options-label">Label width:</span>
116
+ </ToolbarItem>
117
+ <ToolbarItem>
118
+ <ButtonGroup aria-labelledby="label-width-options-label">
119
+ <Button
120
+ color={labelWidth === 'default' ? 'selected' : 'secondary'}
121
+ label="default"
122
+ onClick={() => setLabelWidth('default')}
123
+ />
124
+ <Button
125
+ color={labelWidth === 'auto' ? 'selected' : 'secondary'}
126
+ label="auto"
127
+ onClick={() => setLabelWidth('auto')}
128
+ />
129
+ <Button
130
+ color={labelWidth === 'limited' ? 'selected' : 'secondary'}
131
+ label="limited"
132
+ onClick={() => setLabelWidth('limited')}
133
+ />
134
+ <Button
135
+ color={labelWidth === 'custom' ? 'selected' : 'secondary'}
136
+ label="custom"
137
+ onClick={() => setLabelWidth('custom')}
138
+ />
139
+ </ButtonGroup>
140
+ </ToolbarItem>
141
+ {labelWidth === 'custom' && (
142
+ <ToolbarItem>
143
+ <TextField
144
+ inputSize={5}
145
+ isLabelVisible={false}
146
+ label="Custom label width"
147
+ layout="horizontal"
148
+ onChange={(e) => setCustomLabelWidth(e.target.value)}
149
+ value={customLabelWidth}
150
+ />
151
+ </ToolbarItem>
152
+ )}
153
+ </Toolbar>
154
+ <FormLayout
155
+ fieldLayout="horizontal"
156
+ labelWidth={labelWidth === 'custom' ? customLabelWidth : labelWidth}
157
+ >
158
+ <TextField label="A form element" />
159
+ <TextField
160
+ label={'Another form element with a very long label that is so '
161
+ + 'long that in the auto mode, it should make the label column '
162
+ + 'grow until the inputs reach the end of the line, but it will '
163
+ + 'not exceed 50 % of the FormLayout width in the limited label '
164
+ + 'width mode'}
165
+ />
166
+ <TextField label="Yet another one" />
167
+ </FormLayout>
168
+ </div>
169
+ );
170
+ });
171
+ ```
172
+
173
+ ### Limitations
174
+
175
+ #### Label Position
176
+
177
+ Label position of inline form fields (CheckboxField, Toggle) is ignored in
178
+ horizontal FormLayout.
179
+
180
+ #### Modals
181
+
182
+ Please note the `auto` and `limited` label width options may not function
183
+ correctly in combination with other auto layout mechanisms, e.g. the auto-width
184
+ [Modal](/components/Modal). It's just too much of magic that does not quite
185
+ work together yet 🎩.
186
+
187
+ ## Custom Fields
188
+
189
+ You can even place any content you need into the FormLayout — just wrap it with
190
+ the FormLayoutCustomField component. This layout
191
+ helper ensures your content is properly spaced and aligned with to other
192
+ FormLayout elements. FormLayoutCustomFields are designed to work solely inside
193
+ the FormLayout component.
194
+
195
+ ```docoff-react-preview
196
+ <FormLayout fieldLayout="horizontal" labelWidth="auto">
197
+ <TextField label="A form element" />
198
+ <FormLayoutCustomField label="Optional custom field label">
199
+ <docoff-placeholder bordered>Custom field content</docoff-placeholder>
200
+ </FormLayoutCustomField>
201
+ <TextField label="Another form element" />
202
+ </FormLayout>
203
+ ```
204
+
205
+ 👉 While you can set FormLayoutCustomField as `disabled`, `valid` or `required`
206
+ and its styles may affect contained form fields through CSS cascade, don't
207
+ forget to mirror the aforementioned properties to the contained form fields too
208
+ as API options as such are **not** inherited.
209
+
210
+ ### Label Alignment
211
+
212
+ If you are in a situation with one or more box form fields inside your
213
+ FormLayoutCustomField, you may want to have its label aligned with the fields
214
+ inside. Since it's [not quite possible to do this automatically][rui-265] due to
215
+ limited browser support, there is `innerFieldSize` option which accepts any of
216
+ existing box field sizes (small, medium, or large) and is intended right for
217
+ this task.
218
+
219
+ ```docoff-react-preview
220
+ <FormLayout fieldLayout="horizontal" labelWidth="auto">
221
+ <TextField label="A form element" />
222
+ <FormLayoutCustomField
223
+ innerFieldSize="medium"
224
+ label="Custom field label aligned to inner text input"
225
+ >
226
+ <TextField
227
+ isLabelVisible={false}
228
+ label="A form element"
229
+ placeholder="Text field with invisible label"
230
+ />
231
+ </FormLayoutCustomField>
232
+ <TextField label="Another form element" />
233
+ </FormLayout>
234
+ ```
235
+
236
+ ### Validation States
237
+
238
+ Custom fields support the same validation states as regular form fields to
239
+ provide labels with optional feedback style.
240
+
241
+ ```docoff-react-preview
242
+ <FormLayout fieldLayout="horizontal" labelWidth="auto">
243
+ <TextField label="A form element" />
244
+ <FormLayoutCustomField
245
+ label="Custom field label in valid state"
246
+ validationState="valid"
247
+ >
248
+ <docoff-placeholder bordered>Custom field content</docoff-placeholder>
249
+ </FormLayoutCustomField>
250
+ <TextField label="Another form element" />
251
+ </FormLayout>
252
+ ```
253
+
254
+ ### Accessibility
255
+
256
+ If possible, use the `labelForId` option to provide ID of contained form field
257
+ so the field remains accessible via custom field label.
258
+
259
+ You can also specify size of contained form field so custom field label is
260
+ properly vertically aligned.
261
+
262
+ ```docoff-react-preview
263
+ React.createElement(() => {
264
+ const [isChecked, setIsChecked] = React.useState(false);
265
+ return (
266
+ <FormLayout fieldLayout="horizontal" labelWidth="auto">
267
+ <TextField label="A form element" />
268
+ <FormLayoutCustomField
269
+ fullWidth
270
+ label="Custom field label aligned with medium form field"
271
+ labelForId="my-text-field-custom-accessibility-2"
272
+ innerFieldSize="medium"
273
+ >
274
+ <Toolbar align="middle" dense>
275
+ <ToolbarItem>
276
+ <TextField
277
+ isLabelVisible={false}
278
+ label="A form element"
279
+ placeholder="Text field with invisible label"
280
+ />
281
+ </ToolbarItem>
282
+ <ToolbarItem>
283
+ <CheckboxField
284
+ checked={isChecked}
285
+ label="Another form field"
286
+ onChange={() => setIsChecked(!isChecked)}
287
+ />
288
+ </ToolbarItem>
289
+ </Toolbar>
290
+ </FormLayoutCustomField>
291
+ <TextField label="Another form element" />
292
+ </FormLayout>
293
+ )
294
+ });
295
+ ```
296
+
297
+ ## Full Example
298
+
299
+ This is a demo of all components supported by FormLayout.
300
+
301
+ ```docoff-react-preview
302
+ React.createElement(() => {
303
+ const [fieldLayout, setFieldLayout] = React.useState('vertical');
304
+ const [fruit, setFruit] = React.useState('apple');
305
+ const [isDeliveryAddress, setIsDeliveryAddress] = React.useState(true);
306
+ const [receiveNewsletter, setReceiveNewsletter] = React.useState(true);
307
+ const options = [
308
+ {
309
+ label: 'Apple',
310
+ value: 'apple',
311
+ },
312
+ {
313
+ label: 'Banana',
314
+ value: 'banana',
315
+ },
316
+ {
317
+ label: 'Grapefruit',
318
+ value: 'grapefruit',
319
+ },
320
+ ];
321
+ return (
322
+ <div>
323
+ <Toolbar>
324
+ <ToolbarItem>
325
+ <ButtonGroup>
326
+ <Button
327
+ color={fieldLayout === 'vertical' ? 'selected' : 'secondary'}
328
+ label="Vertical layout"
329
+ onClick={() => setFieldLayout('vertical')}
330
+ />
331
+ <Button
332
+ color={fieldLayout === 'horizontal' ? 'selected' : 'secondary'}
333
+ label="Horizontal layout"
334
+ onClick={() => setFieldLayout('horizontal')}
335
+ />
336
+ </ButtonGroup>
337
+ </ToolbarItem>
338
+ </Toolbar>
339
+ <FormLayout fieldLayout={fieldLayout} labelWidth="auto">
340
+ <>
341
+ <TextField
342
+ label="First Name"
343
+ />
344
+ <TextField
345
+ label="Last Name"
346
+ />
347
+ </>
348
+ <TextField
349
+ helpText="Optional"
350
+ label="Email address"
351
+ type="email"
352
+ />
353
+ <>
354
+ <TextField
355
+ label="Address"
356
+ placeholder="Address line 1"
357
+ />
358
+ <TextField
359
+ isLabelVisible={false}
360
+ label="Address 2"
361
+ placeholder="Address line 2"
362
+ />
363
+ <TextField
364
+ inputSize={6}
365
+ label="ZIP"
366
+ validationState="invalid"
367
+ validationText="ZIP should be 5 to 6 digits long code."
368
+ />
369
+ <FormLayoutCustomField label="Country">
370
+ <span>Czech Republic</span>
371
+ </FormLayoutCustomField>
372
+ <CheckboxField
373
+ checked={isDeliveryAddress}
374
+ helpText="Uncheck if you wish to deliver to a different address."
375
+ label="This is my delivery address"
376
+ onChange={() => setIsDeliveryAddress(!isDeliveryAddress)}
377
+ />
378
+ </>
379
+ <SelectField
380
+ label="Your favourite fruit"
381
+ onChange={(e) => setFruit(e.target.value)}
382
+ options={options}
383
+ value={fruit}
384
+ />
385
+ <TextArea
386
+ fullWidth
387
+ label="Message"
388
+ rows={3}
389
+ />
390
+ <FileInputField
391
+ label="Attachment"
392
+ />
393
+ <Toggle
394
+ checked={receiveNewsletter}
395
+ helpText="Only once per week!"
396
+ label="Receive weekly newsletter"
397
+ onChange={() => setReceiveNewsletter(!receiveNewsletter)}
398
+ required
399
+ />
400
+ <Radio
401
+ label="And fruit again!"
402
+ onChange={(e) => setFruit(e.target.value)}
403
+ options={options}
404
+ value={fruit}
405
+ />
406
+ <InputGroup label="Promo code">
407
+ <TextField label="Code" />
408
+ <Button label="Apply" color="secondary" priority="outline" />
409
+ </InputGroup>
410
+ </FormLayout>
411
+ </div>
412
+ )
413
+ });
414
+ ```
415
+
416
+ ## Forwarding HTML Attributes
417
+
418
+ In addition to the options below in the [component's API](#api) section, you
419
+ can specify [React synthetic events] or **any HTML attribute you like.** All
420
+ attributes that don't interfere with the API are forwarded to the root `<div>`
421
+ HTML element. This enables making the component interactive and helps to improve
422
+ its accessibility.
423
+
424
+ 👉 Refer to the MDN reference for the full list of supported attributes of the
425
+ [div] element.
426
+
427
+ ## API
428
+
429
+ <docoff-react-props src="/components/FormLayout/FormLayout.jsx"></docoff-react-props>
430
+
431
+ ### FormLayoutCustomField API
432
+
433
+ A place for custom content inside FormLayout.
434
+
435
+ <docoff-react-props src="/components/FormLayout/FormLayoutCustomField.jsx"></docoff-react-props>
436
+
437
+ ## Theming
438
+
439
+ | Custom Property | Description |
440
+ |------------------------------------------------------|--------------------------------------------------------------|
441
+ | `--rui-FormLayout__row-gap` | Gap between individual rows |
442
+ | `--rui-FormLayout--horizontal__label__width` | Default label width |
443
+ | `--rui-FormLayout--horizontal__label__width--auto` | Label width in automatic layout |
444
+ | `--rui-FormLayout--horizontal__label__width--limited` | Label width in limited-width layout |
445
+
446
+ ### FormLayoutCustomField Theming
447
+
448
+ FormLayoutCustomField can be styled using a small subset of
449
+ [other form fields theming options](/docs/customize/theming/forms).
450
+
451
+ | Custom Property | Description |
452
+ |------------------------------------------------------|--------------------------------------------------------------|
453
+ | `--rui-FormField--custom--default__surrounding-text-color` | Custom field label color in default state |
454
+ | `--rui-FormField--custom--disabled__surrounding-text-color` | Custom field label color in disabled-like state |
455
+
456
+ [grid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
457
+ [subgrid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid
458
+ [fragments]: https://reactjs.org/docs/fragments.html
459
+ [rui-232]: https://github.com/react-ui-org/react-ui/issues/232
460
+ [rui-265]: https://github.com/react-ui-org/react-ui/issues/265
461
+ [React synthetic events]: https://reactjs.org/docs/events.html
462
+ [div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
@@ -118,7 +118,7 @@ Grid.propTypes = {
118
118
  */
119
119
  children: PropTypes.node,
120
120
  /**
121
- * Gap between columns. Accepts any of [spacing values](/foundation/spacing-values) as number.
121
+ * Gap between columns. Accepts any of [spacing values](/docs/foundation/spacing-values) as number.
122
122
  * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) for more about `column-gap`.
123
123
  */
124
124
  columnGap: PropTypes.oneOfType([
@@ -182,7 +182,7 @@ Grid.propTypes = {
182
182
  }),
183
183
  ]),
184
184
  /**
185
- * Gap between rows. Accepts any of [spacing values](/foundation/spacing-values) as number.
185
+ * Gap between rows. Accepts any of [spacing values](/docs/foundation/spacing-values) as number.
186
186
  * See [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) for more about `row-gap`.
187
187
  */
188
188
  rowGap: PropTypes.oneOfType([